public void UpdatePassword(UserPasswordViewModel model) { var mapper = CustomMapperConfiguration.ConfigCreateMapper <UserPasswordViewModel, User>(); //var config = new MapperConfiguration(c => //{ // c.CreateMap<UserPasswordViewModel, User>(); // c.IgnoreUnmapped(); //}); //var mapper = config.CreateMapper(); var user = mapper.Map <UserPasswordViewModel, User>(model); user.Password = Sha256HashGenerator.GenerateHash(model.Password); _usersRepository.UpdatePassword(user); }
public int Insert(RegisterViewModel model) { var mapper = CustomMapperConfiguration.ConfigCreateMapper <RegisterViewModel, User>(); //var config = new MapperConfiguration(c => //{ // c.CreateMap<RegisterViewModel, User>(); // c.IgnoreUnmapped(); //}); //var mapper = config.CreateMapper(); var user = mapper.Map <RegisterViewModel, User>(model); user.Password = Sha256HashGenerator.GenerateHash(model.Password); _usersRepository.Insert(user); return(_usersRepository.GetRecentUser()); }
public UserViewModel GetByEmailPassword(string email, string password) { var user = _usersRepository.GetByEmailPassword(email, Sha256HashGenerator.GenerateHash(password)); if (user == null) { return(null); } var mapper = CustomMapperConfiguration.ConfigCreateMapper <User, UserViewModel>(); //var config = new MapperConfiguration(c => //{ // c.CreateMap<User, UserViewModel>(); // c.IgnoreUnmapped(); //}); //var mapper = config.CreateMapper(); return(mapper.Map <User, UserViewModel>(user)); }