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); }
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); }
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); }