public async Task <ValidationModelResult> Registrate(UserModelResult user) { UserModelEntity userEntity = await _userRepository.GetUser(user.Email); if (userEntity != null) { var errorMessage = new Dictionary <string, string>(); errorMessage.Add("Email", "Email is exist"); return(new ValidationModelResult() { IsValid = false, ErrorMessages = errorMessage }); } user.Password = _securityService.Encrypte(user.Password); userEntity = _mapper.Map <UserModelResult, UserModelEntity>(user); await _userRepository.Create(userEntity); return(new ValidationModelResult() { IsValid = true }); }
public async Task <UserModelResult> Login(LoginModelResult loginModelResult) { var hashPassword = _securityService.Encrypte(loginModelResult.Password); UserModelEntity userEntity = await _userRepository.GetUser(loginModelResult.Username, hashPassword); UserModelResult user = _mapper.Map <UserModelEntity, UserModelResult>(userEntity); return(user); }