コード例 #1
0
        public void UpdateUserPassword(EditUserPasswordViewModel uvm)
        {
            var     config = new MapperConfiguration(cfg => { cfg.CreateMap <EditUserPasswordViewModel, User>(); cfg.IgnoreUnmapped(); });
            IMapper mapper = config.CreateMapper();
            User    u      = mapper.Map <EditUserPasswordViewModel, User>(uvm);

            u.PasswordHash = SHA256HashGenerator.GenerateHash(uvm.Password);
            ur.UpdateUserPassword(u);
        }
コード例 #2
0
        public int InsertUser(RegisterViewModel uvm)
        {
            var     config = new MapperConfiguration(cfg => { cfg.CreateMap <RegisterViewModel, User>(); cfg.IgnoreUnmapped(); });
            IMapper mapper = config.CreateMapper();
            User    u      = mapper.Map <RegisterViewModel, User>(uvm);

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

            return(uid);
        }
コード例 #3
0
        public UserViewModel GetUsersByEmailAndPassword(string Email, string Password)
        {
            User          u   = ur.GetUsersByEmailAndPassword(Email, SHA256HashGenerator.GenerateHash(Password)).FirstOrDefault();
            UserViewModel uvm = null;

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