Esempio n. 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();
        }
Esempio n. 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));
        }
Esempio n. 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();
        }