// GET: Employees #region login verification and employees display public ActionResult Index() { //if log in is autenticated proceed to showing employee page if (Session["authenticated"] != null && (bool)Session["authenticated"] == true) { var EmployeeData = employeeBL.GetEmployees(); var UserFlName = Session["UserDisplay"]; ViewBag.userFlName = UserFlName; List <EmployeeShifts> employeeShiftList = ConvertToDataModel(EmployeeData); ViewBag.employee = employeeShiftList; #region activity count /*Activity section start*/ var currentActivityCount = new UserActivityLogBL().AddUserActivityToLog(); if (currentActivityCount > int.Parse(Session["ActivityLimit"].ToString())) { return(RedirectToAction("LogOut", "LogIn", new { IsOverLimit = true })); } /*Activity section end*/ #endregion return(View("Employees")); } else { return(RedirectToAction("Index", "LogIn")); } }
public ActionResult GetLoginData(string username, string password) { //authenticating user by user name and password var user = loginBL.IsAuthenticated(username, password); if (user != null) { Session["authenticated"] = true; var result = loginBL.GetUsers(); ViewBag.userFlName = result; //saving loged user's data (full name and activity limit) for presenting Session["UserFlName"] = user.FullName; Session["UserID"] = user.ID; Session["ActivityLimit"] = user.NumOfActions; // var activityCount = new UserActivityLogBL().GetUserActivityCount(); if (activityCount > user.NumOfActions) { return(LogOut(true)); } //saving user's activity count for presenting Session["ActivityCount"] = activityCount; // saving a summarised sentence for presenting Session["UserDisplay"] = $"{user.FullName} (Action made: {activityCount} out of {user.NumOfActions})"; return(RedirectToAction("HomePage", "HomePage")); } else { //if not authenticated - directed to login screen Session["authenticated"] = false; return(RedirectToAction("Index", "LogIn")); } }
public ActionResult DeleteEmployee(int id) { employeeBL.DeleteEmployee(id); #region activity count /*Activity section start*/ var currentActivityCount = new UserActivityLogBL().AddUserActivityToLog(); if (currentActivityCount > int.Parse(Session["ActivityLimit"].ToString())) { return(RedirectToAction("LogOut", "LogIn", new { IsOverLimit = true })); } /*Activity section end*/ #endregion return(RedirectToAction("Index")); }
public ActionResult AddShift() { var UserFlName = Session["UserDisplay"]; ViewBag.userFlName = UserFlName; #region activaty count /*Activity section start*/ var currentActivityCount = new UserActivityLogBL().AddUserActivityToLog(); if (currentActivityCount > int.Parse(Session["ActivityLimit"].ToString())) { return(RedirectToAction("LogOut", "LogIn", new { IsOverLimit = true })); } /*Activity section end*/ #endregion return(View("AddShift")); }
public ActionResult GetEditedEmployeeFromUser(Employee emp) { employeeBL.EditEmployee(emp); #region activity count /*Activity section start*/ var currentActivityCount = new UserActivityLogBL().AddUserActivityToLog(); if (currentActivityCount > int.Parse(Session["ActivityLimit"].ToString())) { return(RedirectToAction("LogOut", "LogIn", new { IsOverLimit = true })); } /*Activity section end*/ #endregion var UserFlName = Session["UserDisplay"]; ViewBag.userFlName = UserFlName; return(RedirectToAction("Index")); }
// GET: Departments #region login verification and department display public ActionResult Index(bool success = true) { //if log in is autenticated proceed to department page if (Session["authenticated"] != null && (bool)Session["authenticated"] == true) { var UserFlName = Session["UserDisplay"]; ViewBag.userFlName = UserFlName; if (!success) { ViewBag.status = false; } else { ViewBag.status = true; } var DepartmentData = departmentsBL.GetDepartments(); var departmentemployeesList = new List <Employees>(); // run all records from DB foreach (var depItem in DepartmentData) { //find if emplyee exsist in my list var currDep = departmentemployeesList.FirstOrDefault(x => x.Department == depItem.Name); } ViewBag.department = DepartmentData; #region activity count /*Activity section start*/ var currentActivityCount = new UserActivityLogBL().AddUserActivityToLog(); if (currentActivityCount > int.Parse(Session["ActivityLimit"].ToString())) { return(RedirectToAction("LogOut", "LogIn", new { IsOverLimit = true })); } /*Activity section end*/ #endregion return(View("Departments")); } else { return(RedirectToAction("Index", "LogIn")); } }
public ActionResult GetNewDepartmentFromUser(Department dep) { var UserFlName = Session["UserDisplay"]; ViewBag.userFlName = UserFlName; departmentsBL.AddDepartment(dep); #region activaty count /*Activity section start*/ var currentActivityCount = new UserActivityLogBL().AddUserActivityToLog(); if (currentActivityCount > int.Parse(Session["ActivityLimit"].ToString())) { return(RedirectToAction("LogOut", "LogIn", new { IsOverLimit = true })); } /*Activity section end*/ #endregion return(RedirectToAction("Index")); }
public ActionResult AddEmployee() { //geting departmants info for the drop down selection of departmant var DepartmentData = departmentsBL.GetDepartments(); ViewBag.Departments = DepartmentData; var UserFlName = Session["UserDisplay"]; ViewBag.userFlName = UserFlName; #region activity count /*Activity section start*/ var currentActivityCount = new UserActivityLogBL().AddUserActivityToLog(); if (currentActivityCount > int.Parse(Session["ActivityLimit"].ToString())) { return(RedirectToAction("LogOut", "LogIn", new { IsOverLimit = true })); } /*Activity section end*/ #endregion return(View("NewEmployee")); }
public ActionResult DeleteDepartment(int id) { //restriction for not deleting dep with emoloyees in it var count = departmentsBL.GetDepartmentEmployeeCount(id); if (count > 0) { // if departmant has employee user will be redirected to index action with "Unable to delete..." message return(RedirectToAction("Index", new { success = false })); } //if not contaning employees will proceed to deleting departmentsBL.DeleteDepartment(id); #region activaty count /*Activity section start*/ var currentActivityCount = new UserActivityLogBL().AddUserActivityToLog(); if (currentActivityCount > int.Parse(Session["ActivityLimit"].ToString())) { return(RedirectToAction("LogOut", "LogIn", new { IsOverLimit = true })); } /*Activity section end*/ #endregion return(RedirectToAction("Index")); }
public ActionResult EmployeeSearchResult(string phrase) { //getting a phrase and checking if it's or a part of it is equal to name/last name/department name of employees var result = employeeBL.Search(phrase); List <EmployeeShifts> employeeShiftList = ConvertToDataModel(result); ViewBag.employee = employeeShiftList; var UserFlName = Session["UserDisplay"]; ViewBag.userFlName = UserFlName; #region activity count /*Activity section start*/ var currentActivityCount = new UserActivityLogBL().AddUserActivityToLog(); if (currentActivityCount > int.Parse(Session["ActivityLimit"].ToString())) { return(RedirectToAction("LogOut", "LogIn", new { IsOverLimit = true })); } /*Activity section end*/ #endregion return(View("Employees")); }
// GET: Shifts #region varification and shift display public ActionResult Index() { //if log in is autenticated proceed to showing shifts page if (Session["authenticated"] != null && (bool)Session["authenticated"] == true) { var ShiftsData = shiftBL.GetShifts(); var shiftEmployees = new List <ShiftEmployees>(); foreach (var shiftItem in ShiftsData) { //find if shift already exsists in the list var shiftEmployee = shiftEmployees.FirstOrDefault(x => x.ShiftId == shiftItem.ShiftId); //if exsist add employee record to shift if (shiftEmployee != null) { if (shiftItem.EmployeeId.HasValue) { shiftEmployee.Employees.Add(new EmployeeInfo { EmployeeId = shiftItem.EmployeeId.Value, FullName = $"{shiftItem.FirstName} {shiftItem.LastName}" }); } } //if not exsist create new shift with its employee else { //firest create the base class shiftEmployee = new ShiftEmployees { ShiftId = shiftItem.ShiftId, Date = shiftItem.Date, Time = $"{shiftItem.StartTime} to {shiftItem.EndTime}" }; //Then add the first employee info if (shiftItem.EmployeeId.HasValue) { shiftEmployee.Employees.Add(new EmployeeInfo { EmployeeId = shiftItem.EmployeeId.Value, FullName = $"{shiftItem.FirstName} {shiftItem.LastName}" }); } shiftEmployees.Add(shiftEmployee); } } ViewBag.Shifts = shiftEmployees; var UserFlName = Session["UserDisplay"]; ViewBag.userFlName = UserFlName; #region activity count /*Activity section start*/ var currentActivityCount = new UserActivityLogBL().AddUserActivityToLog(); if (currentActivityCount > int.Parse(Session["ActivityLimit"].ToString())) { return(RedirectToAction("LogOut", "LogIn", new { IsOverLimit = true })); } /*Activity section end*/ #endregion return(View("shifts")); } else { return(RedirectToAction("Index", "LogIn")); } }