Пример #1
0
        public async Task <(bool Succeed, string ErrorMessage)> Register(RegisterView userInfo)
        {
            if (await Dapper.ExecuteScalarAsync <int>("select count(1) from Users where email=@Email",
                                                      new { userInfo.Email }) > 0)
            {
                return(false, "Email address already exists");
            }
            var ok = await Dapper.ExecuteAsync(
                "insert into Users(email,password,nickname) values(@Email,@Password,@NickName);", new
            {
                userInfo.Email,
                Password = BCryptor.Encrypt(userInfo.Password),
                userInfo.NickName
            }) > 0;

            return(ok ? (true, "") : (false, "Registration failed"));
        }