Ejemplo n.º 1
0
 public ActionResult Login([Bind(Include = "Username,Password")] string username, string password)
 {
     if (administratorRepository.Login(username, Configuration.Encryption(password)).IsSuccessStatusCode)
     {
         Session["Username"]    = username;
         Session["UserID"]      = administratorRepository.ReadByUsername(username).PersonalCode;
         Session["AccessLevel"] = "Administrator";
         return(RedirectToAction("Index", "Admin"));
     }
     else if (guardRepository.Login(username, Configuration.Encryption(password)).IsSuccessStatusCode)
     {
         Session["Username"]    = username;
         Session["UserID"]      = guardRepository.ReadByUsername(username).PersonalCode;
         Session["AccessLevel"] = "Guard";
         return(RedirectToAction("Index", "Guard"));
     }
     else if (residentRepository.Login(username, Configuration.Encryption(password)).IsSuccessStatusCode)
     {
         Session["Username"]    = username;
         Session["UserID"]      = residentRepository.ReadByUsername(username).PersonalCode;
         Session["AccessLevel"] = "Resident";
         return(RedirectToAction("Index", "Resident"));
     }
     else
     {
         return(RedirectToAction("LoginForm"));
         //nepaejo prisijungti vairantas
     }
 }
        public LoginAnswer Login(Administrator administrator)
        {
            LoginAnswer loginAnswer = new LoginAnswer();

            try
            {
                loginAnswer.Error = false;
                connectionManager.OpenConnection();
                loginAnswer.ValidData = administratorRepository.Login(administrator);
                return(loginAnswer);
            }
            catch (Exception e)
            {
                loginAnswer.Error   = true;
                loginAnswer.Message = $"Error de aplicacion {e.Message}";
                return(loginAnswer);
            }
            finally { connectionManager.CloseConnection(); }
        }
 public async Task <AdminLoginUserInfo> Login(AdminLoginInput input)
 {
     return(Mapper.Map <Administrator, AdminLoginUserInfo>(await _repository.Login(input)));
 }