Example #1
0
        // GET: Employee
        public ActionResult Index()
        {
            if (Session["authenticated"] != null && (bool)Session["authenticated"] == true)
            {
                // logic to count user actions
                var userName = Session["userName"] as string;
                loginBL.UpdateActionCounter(userName);
                var amountActions = loginBL.GetUpdateActionsForUser(userName);
                Session["AmountOfActions"] = amountActions;
                if (amountActions < 0)
                {
                    TempData["ErrorMessage"] = "Logout out by the system! user doesn't have actions";
                    Session.Clear();
                    return(RedirectToAction("Index", "Login"));
                }

                var serachedList = TempData["searchedList"] as List <EmployeeWithDepDTO>;
                if (serachedList != null)
                {
                    ViewBag.employees = serachedList;
                }
                else
                {
                    ViewBag.employees = employeeBL.GetEmployeesWithDepartment();
                }
                ViewBag.shifts = employeeShiftBL.GetShiftsForEmployee();
                return(View());
            }
            return(RedirectToAction("Index", "Login"));
        }
Example #2
0
 // GET: Department
 public ActionResult Index()
 {
     if (Session["authenticated"] != null && (bool)Session["authenticated"] == true)
     {
         // logic to count user actions
         var userName = Session["userName"] as string;
         loginBL.UpdateActionCounter(userName);
         var amountActions = loginBL.GetUpdateActionsForUser(userName);
         Session["AmountOfActions"] = amountActions;
         if (amountActions < 0)
         {
             TempData["ErrorMessage"] = "Logout out by the system! user doesn't have actions";
             Session.Clear();
             return(RedirectToAction("Index", "Login"));
         }
         else
         {
             var model = departmentBL.GetAll();
             foreach (var item in model)
             {
                 item.isExist = departmentBL.IsEmployeeInDepartment(item.DepId);
             }
             return(View(model));
         }
     }
     return(RedirectToAction("Index", "Login"));
 }
Example #3
0
        public ActionResult Index(user user)
        {
            bool authenticated = loginBL.IsAuthenticated(user);

            if (authenticated)
            {
                Session["authenticated"] = true;
                // present user full name in nav-bar
                string userFullName = loginBL.GetUserFullName(user.UserName);
                Session["userFullName"] = userFullName;

                // all controllers will check action for selected uesr
                Session["userName"] = user.UserName;
                //update dataBase for currentUser
                loginBL.UpdateActions(user.UserName);

                // present user actions in nav-bar
                var selectedUser = loginBL.GetUser(user.UserName);
                Session["AmountOfActions"] = selectedUser.ActionsCounter;

                // user used all of his actions
                if (loginBL.GetUpdateActionsForUser(user.UserName) < 0)
                {
                    Session.Clear();
                    TempData["ErrorMessage"] = "Logout by the system! user doesn't have actions";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View("HomePage"));
                }
            }
            else
            {
                Session["authenticated"] = false;
                TempData["ErrorMessage"] = "Login Failed! Such a user doesn't exist on the site";
                return(RedirectToAction("Index"));
            }
        }