Пример #1
0
        public IActionResult MyCals()
        {
            User CurrentUser = UserFactory.LogInUser(HttpContext.Session.GetString(CookieKeys.USERNAME), HttpContext.Session.GetString(CookieKeys.PASSWORD));

            if (CurrentUser != null && CurrentUser.Permissions[(int)FeatureEnumeration.OWN_CALS])
            {
                IGrades   ServiceAdapter = new GradesAdapter();
                DataTable Grades         = ServiceAdapter.GetGrades(CurrentUser.IdUser);
                return(View(Grades));
            }
            return(RedirectToAction("Messages", "Home", new { Message = UtilMessages.NO_CREDENTIALS }));
        }
Пример #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 }));
        }
Пример #3
0
        public IActionResult Overview(string UserName, string Password)
        {
            UserCreator UserFactory = new UserCreator();

            //CurrentUser = UserFactory.LogInUser(new UserLogIn { UserName = TempData["User"].ToString(), UserPassword = TempData["Password"].ToString() });
            CurrentUser = UserFactory.LogInUser(new UserLogIn {
                UserName = HttpContext.Session.GetString(CookieKeys.USERNAME), UserPassword = HttpContext.Session.GetString(CookieKeys.PASSWORD)
            });
            //User newUser = UserFactory.CreateUser(AccountType, Name, LastName, SecondLastName, FullName, Address, EMail, Password, UserName, IdUser);
            //ViewData["UserInfo"] = CurrentUser;
            ViewData["Options"] = FeatureManager.GetFeatures(CurrentUser.Permissions);

            //ViewData["Options"] = newUser.Permissions;
            //ViewData["OptionNames"] = EnumUtils.GetOptions();
            return(View(CurrentUser));
        }