示例#1
0
        public void UpdateUserPassword(EditUserPasswordViewModel editUserPasswordViewModel)
        {
            var     config = new MapperConfiguration(cfg => { cfg.CreateMap <EditUserPasswordViewModel, User>(); cfg.IgnoreUnmapped(); });
            IMapper mapper = config.CreateMapper();
            User    user   = mapper.Map <EditUserPasswordViewModel, User>(editUserPasswordViewModel);

            user.PasswordHash = SHA256HashGenerator.GenerateHash(editUserPasswordViewModel.Password);
            usersRepository.UpdateUserPassword(user);
        }
示例#2
0
        public int InsertUser(RegisterViewModel registerViewModel)
        {
            var     config = new MapperConfiguration(cfg => { cfg.CreateMap <RegisterViewModel, User>(); cfg.IgnoreUnmapped(); });
            IMapper mapper = config.CreateMapper();
            User    user   = mapper.Map <RegisterViewModel, User>(registerViewModel);

            user.PasswordHash = SHA256HashGenerator.GenerateHash(registerViewModel.Password);
            usersRepository.InsertUser(user);
            int lastestUser = usersRepository.GetLatestUserID();

            return(lastestUser);
        }
示例#3
0
        public UserViewModel GetUsersByEmailAndPassword(string Email, string Password)
        {
            User          existUser      = usersRepository.GetUsersByEmailAndPassword(Email, SHA256HashGenerator.GenerateHash(Password));
            UserViewModel usersViewModel = null;

            if (existUser != null)
            {
                var     config = new MapperConfiguration(cfg => { cfg.CreateMap <User, UserViewModel>(); cfg.IgnoreUnmapped(); });
                IMapper mapper = config.CreateMapper();
                usersViewModel = mapper.Map <User, UserViewModel>(existUser);
            }
            return(usersViewModel);
        }