SET ANSI_NULLS ON;
GO
SET QUOTED_IDENTIFIER ON;
GO

CREATE OR ALTER PROCEDURE dbo.User_Create
    @Email nvarchar(256),
    @DisplayName nvarchar(200),
    @PasswordHash nvarchar(max),
    @EmailConfirmed bit = 0
AS
BEGIN
    SET NOCOUNT ON;

    INSERT INTO dbo.AppUser (Email, DisplayName, PasswordHash, EmailConfirmed)
    VALUES (@Email, @DisplayName, @PasswordHash, @EmailConfirmed);

    DECLARE @UserID int = SCOPE_IDENTITY();

    EXEC dbo.User_GetById @UserID = @UserID;
END;
GO
