Пример #1
0
        public ActionResult LoginPart(string email, string password)
        {
            var admin = db.Person.Where(w => w.Email == email || w.Phone == email).FirstOrDefault();

            if (admin != null)
            {
                string HashPassword = PasswordExtention.HashPassword(password);
                if (admin.Password == password && (admin.Email == email || admin.Phone == email))
                {
                    var adminSession = new SessionKey();
                    Session[SessionKey.Admin] = email;

                    var x = Session[SessionKey.Admin];
                    return(RedirectToAction("Index", "Admin"));
                }
                else
                {
                    ViewBag.Login = "******";
                    return(View());
                }
            }
            else
            {
                ViewBag.Login = "******";
                return(View());
            }
        }
Пример #2
0
        public int Register(AccountDTO register)
        {
            // convert AccountDTO to Account object using auto mapper
            register.Password = PasswordExtention.GenerateUserPassword(register.Password);
            var autoMap = _autoMapper.Map <Account>(register);
            var result  = _accountRepository.Create(autoMap);

            return(result);
        }
Пример #3
0
        public int?Login(LoginDTO login)
        {
            var account = new Account
            {
                Phone    = login.Phone,
                Password = PasswordExtention.GenerateUserPassword(login.Password)
            };
            var result = _accountRepository.Get(account);

            return(result?.Id);
        }