public void Insert(UserDTO userDto) { var user = _mapper.Map <User>(userDto); user.Password = HashAlgorithm.CreateMD5(userDto.Password); _unitOfWork.Users.Insert(user); _unitOfWork.Save(); }
public UserDTO GetUser(string email, string password) { var passwordHash = HashAlgorithm.CreateMD5(password); var user = _unitOfWork.Users .Find(u => u.Email == email && u.Password == passwordHash) .FirstOrDefault(); return(_mapper.Map <UserDTO>(user)); }
public void Insert(UserDTO userDto) { if (EmailTaken(userDto.Email)) { throw new Exception("Email is already registered!"); } var user = _mapper.Map <User>(userDto); user.Password = HashAlgorithm.CreateMD5(userDto.Password); _unitOfWork.Users.Insert(user); _unitOfWork.Save(); }