Ejemplo n.º 1
0
        public void UpdateUserPassword(EditUserPasswordViewModel user)
        {
            var     config = new MapperConfiguration(cfg => { cfg.CreateMap <EditUserPasswordViewModel, User>(); cfg.IgnoreUnmapped(); });
            IMapper mapper = config.CreateMapper();
            User    u      = mapper.Map <EditUserPasswordViewModel, User>(user);

            u.PasswordHash = SHA256HashGenerator.GenerateHash(user.Password);
            ur.UpdateUserPassword(u);
        }
Ejemplo n.º 2
0
        public int InsertUser(RegisterViewModel rvm)
        {
            var     config = new MapperConfiguration(cfg => { cfg.CreateMap <RegisterViewModel, User>(); cfg.IgnoreUnmapped(); });
            IMapper mapper = config.CreateMapper();
            User    u      = mapper.Map <RegisterViewModel, User>(rvm);

            u.PasswordHash = SHA256HashGenerator.GenerateHash(rvm.Password);
            ur.InsertUser(u);
            int uid = ur.GetLatestUserID();

            return(uid);
        }
Ejemplo n.º 3
0
        public UserViewModel GetUsersByEmailAndPassword(string email, string password)
        {
            User          users = ur.GetUsersByEmailAndPassword(email, SHA256HashGenerator.GenerateHash(password)).SingleOrDefault();
            UserViewModel uvm   = null;

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