Beispiel #1
0
        public void Insert(UserDTO userDto)
        {
            var user = _mapper.Map <User>(userDto);

            user.Password = HashAlgorithm.CreateMD5(userDto.Password);
            _unitOfWork.Users.Insert(user);
            _unitOfWork.Save();
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        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();
        }