示例#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"));
        }