예제 #1
0
        public async Task <SignInOutput> ExecuteAsync(SignUpInput input)
        {
            await AssertLoginIsNotBusyAsync(input.Login);

            var encryptedPassword = PasswordEncoder.Encrypt(input.Password);
            var user = new UserEntity(input.FirstName, input.LastName, input.Login, encryptedPassword, UserRole.Client);

            await UserRepository.SaveAndFlushAsync(user);

            return(new SignInOutput(user, TokenService.CreateToken(user)));
        }
 public static async Task InsertUser(this ITable <UserEntity> users, NewUserModel user)
 {
     await users
     .Value(u => u.FirstName, user.FirstName)
     .Value(u => u.LastName, user.LastName)
     .Value(u => u.Age, user.Age)
     .Value(u => u.Phone, user.Phone)
     .Value(u => u.Username, user.Username)
     .Value(u => u.Password, PasswordEncoder.Encrypt(user.Password))
     .InsertAsync();
 }
 public static async Task UpdatetUser(this ITable <UserEntity> users, NewUserModel user, int userId)
 {
     await users
     .Where(u => u.Id == userId)
     .Set(u => u.FirstName, user.FirstName)
     .Set(u => u.LastName, user.LastName)
     .Set(u => u.Age, user.Age)
     .Set(u => u.Phone, user.Phone)
     .Set(u => u.Username, user.Username)
     .Set(u => u.Password, PasswordEncoder.Encrypt(user.Password))
     .UpdateAsync();
 }
 public static async Task <UserModel> GetUser(this ITable <UserEntity> users, string username, string password)
 {
     return(await users
            .Where(u => u.Username == username && u.Password == PasswordEncoder.Encrypt(password))
            .Select(u => new UserModel
     {
         Id = u.Id,
         FirstName = u.FirstName,
         LastName = u.LastName,
         Age = u.Age,
         Phone = u.Phone,
         Username = u.Username
     })
            .FirstOrDefaultAsync());
 }