Ejemplo n.º 1
0
 public AcademicController(IConfiguration configuration)
 {
     _configuration = configuration;
     _db            = AcademicService.GetInstance;
     _dbUser        = UserDBService.GetInstance;
     UserFactory    = new UserCreator();
 }
Ejemplo n.º 2
0
        public IActionResult LogIn(UserLogIn user)
        {
            UserCreator UserFactory = new UserCreator();
            string      message     = "";

            if (ModelState.IsValid)
            {
                UserDBService UserDB      = UserDBService.GetInstance;
                User          CurrentUser = UserFactory.LogInUser(user);
                if (CurrentUser != null)
                {
                    // Debugging Purposes
                    //TempData["User"] = CurrentUser.UserName;
                    //TempData["Password"] = CurrentUser.Password;

                    //SetCookie("User", CurrentUser.UserName, 2);
                    //SetCookie("Password", CurrentUser.UserName, 2);

                    HttpContext.Session.SetString(CookieKeys.USERNAME, CurrentUser.UserName);
                    HttpContext.Session.SetString(CookieKeys.PASSWORD, CurrentUser.Password);

                    return(RedirectToAction("Overview", "Home"));
                    //return Content(CurrentUser.ToString());
                }
                else
                {
                    message = "Failed to log in. Your information does not match any record in our database.\nIf your information was correct contact your admin.\n\nPlease try again";
                }
            }
            else
            {
                message = "Failed to log in. Unformatted information .\n\nPlease try again";
            }
            return(RedirectToAction("Messages", "Home", new { Message = message }));
        }