public ActionResult Edit(string departmentId, int staffIdContact, int departmentPhone, int departmentFax) { try { if (ModelState.IsValid) { DepartmentDAO.UpdateDepartmentContacts(departmentId, staffIdContact, departmentPhone, departmentFax); return(RedirectToAction("Details")); } string userId = User.Identity.GetUserId(); Staff staff = StaffDepartmentDAO.GetStaffByUserId(userId); Department department = DepartmentDAO.GetDepartmentByUserId(userId); List <Staff> staffList = StaffDepartmentDAO.FindAllStaffInDepartment(staff.departmentId); ViewBag.Department = staff.Department.departmentName; ViewBag.staffIdContact = new SelectList(staffList, "staffId", "staffName", department.staffIdContact); return(View(department)); } catch (Exception e) { return(View("~/Views/Shared/Error.cshtml")); } }
// GET: Departments/Edit public ActionResult Edit(string id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Department department = DbFactory.Instance.context.Departments.Find(id); if (department == null) { return(HttpNotFound()); } List <Staff> staffList = StaffDepartmentDAO.FindAllStaffInDepartment(id); ViewBag.department = department.departmentName; ViewBag.staffIdContact = new SelectList(staffList, "staffId", "staffName", department.staffIdContact); return(View(department)); } catch (Exception e) { return(View("~/Views/Shared/Error.cshtml")); } }
public ActionResult RoleDelegation(List <Staff> Model, int?staffSelected, string removeAuthority, string submit, string startDate, string endDate, int?staffChosen) { string userId = User.Identity.GetUserId(); Staff currentUser = StaffDepartmentDAO.GetStaffByUserId(userId); // If remove authority button is clicked if (removeAuthority != null) { Staff delegatedStaff = StaffDepartmentDAO.GetDelegatedStaff(currentUser.Department); StaffDepartmentDAO.RemoveAuthority(delegatedStaff); // Return updated model //List<Staff> staffList = StaffDepartmentDAO.FindAllStaffInDepartment(currentUser.Department.departmentId).Where(x => x.staffId != currentUser.Department.staffIdDH && x.staffId != currentUser.Department.staffIdDR).ToList(); return(RedirectToAction("RoleDelegation")); } // If submit button is clicked if (submit != null && DateTime.TryParse(startDate, out DateTime d_start) && DateTime.TryParse(endDate, out DateTime d_end)) { StaffDepartmentDAO.GiveAuthority(staffChosen, d_start, d_end); return(RedirectToAction("RoleDelegation")); } ViewBag.DelegatedStaff = StaffDepartmentDAO.GetStaffByStaffId(staffSelected); return(View(Model)); }
public ActionResult ChangeCollectionPoint() { string id = User.Identity.GetUserId(); var staff = StaffDepartmentDAO.GetStaffByUserId(id); Department dep = staff.Department; DepartmentViewModel depView = StaffDepartmentDAO.ConvertDepartmentToDepartmentViewModel(dep); // Set CollectionPoint viewbag here! ViewBag.CollectionPoint = CollectionPointDAO.GetCollectionPoints(); if (User.IsInRole("DH") || User.IsInRole("Temp DH")) { // get DR candidate list List <Staff> possibleList = StaffDepartmentDAO.FindPossibleDRList(staff); possibleList = possibleList == null ? new List <Staff>() : possibleList; Staff currentDR = StaffDepartmentDAO.FindDepartmentRole(staff.departmentId, "DR"); // Set StaffList viewbag here! ViewBag.StaffList = new SelectList( possibleList, "staffId", "staffName", currentDR == null ? -1 : currentDR.staffId); } return(View(depView)); }
public ActionResult List() { string userId = User.Identity.GetUserId(); var s1 = StaffDepartmentDAO.GetStaffByUserId(userId); var reqList = RequestDAO.GetRequests(s1).ToList(); ModelState.Clear(); return(View(reqList)); }
public void saveCollectionPoint(DepartmentViewModel department) { string userId = User.Identity.GetUserId(); Staff s1 = StaffDepartmentDAO.GetStaffByUserId(userId); if (s1 != null) { int cId = department.collectionPointId; CollectionPointDAO.UpdateCollectionPoint(s1.departmentId, cId); } }
public DepartmentViewModel departmentDetails() { string userId = User.Identity.GetUserId(); Staff s1 = StaffDepartmentDAO.GetStaffByUserId(userId); if (s1 == null) { return(null); } Department dep = DepartmentDAO.GetDepartmentByUserId(userId); return(StaffDepartmentDAO.ConvertDepartmentToDepartmentViewModel(dep)); }
public List <RequestViewModel> ReadRequest() { var userId = User.Identity.GetUserId(); Staff s1 = StaffDepartmentDAO.GetStaffByUserId(userId); var reqList = new List <RequestViewModel>(); if (s1 != null) { reqList = RequestDAO.GetRequests(s1); } return(reqList); }
public ActionResult RoleDelegation() { string userId = User.Identity.GetUserId(); Staff currentUser = StaffDepartmentDAO.GetStaffByUserId(userId); //Find all staff that are not DH and DR List <Staff> staffList = StaffDepartmentDAO.FindAllStaffInDepartment(currentUser.Department.departmentId).Where(x => x.staffId != currentUser.Department.staffIdDH && x.staffId != currentUser.Department.staffIdDR).ToList(); Staff delegatedStaff = StaffDepartmentDAO.GetDelegatedStaff(currentUser.Department); //if no staff had been delegated for the period the viewbag will be null ViewBag.DelegatedStaff = delegatedStaff; return(View(staffList)); }
public ActionResult Delete(int requestId) { string userId = User.Identity.GetUserId(); var s1 = StaffDepartmentDAO.GetStaffByUserId(userId); if (s1 != null) { // Delete the request RequestDAO.DeleteRequest(s1.staffId, requestId); } return(RedirectToAction("List")); }
public List <RequestViewModel> ListRequestsByDepartmentId() { string userId = User.Identity.GetUserId(); Staff s1 = StaffDepartmentDAO.GetStaffByUserId(userId); if (s1 == null) { return(null); } List <RequestViewModel> reqList = RequestDAO.GetPendingRequestsInDepartment(s1); return(reqList); }
public ActionResult ApproveReject(string ShowHistory) { TempData["ShowHistory"] = "False"; string userId = User.Identity.GetUserId(); Staff s1 = StaffDepartmentDAO.GetStaffByUserId(userId); List <RequestViewModel> reqList = RequestDAO.GetPendingRequestsInDepartment(s1); if (ShowHistory == "True") { List <RequestViewModel> reqList0 = RequestDAO.GetHistoryRequestsInDepartment(s1); reqList = reqList.Union(reqList0).ToList(); TempData["ShowHistory"] = "True"; } return(View(reqList)); }
public ActionResult ChangeCollectionPoint(Department department, int chosenPoint, int?staffList, int?oldDR) { string id = User.Identity.GetUserId(); var staff = StaffDepartmentDAO.GetStaffByUserId(id); Department dep = staff.Department; CollectionPointDAO.UpdateCollectionPoint(dep.departmentId, chosenPoint); if (User.IsInRole("DH") || User.IsInRole("Temp DH")) { if (staffList != null) { StaffDepartmentDAO.changeDR(staff.staffId, (int)staffList); } } return(View("~/Views/Home/Index.cshtml")); }
public bool RaiseNewRequest([FromBody] List <RequestViewModel> reqDetails) { if (reqDetails == null || reqDetails.Count < 1) { return(false); } string userId = User.Identity.GetUserId(); Staff s1 = StaffDepartmentDAO.GetStaffByUserId(userId); if (s1 == null) { return(false); } bool bRes = RequestDAO.RaiseRequest(s1.staffId, s1.departmentId, reqDetails); return(bRes); }
public bool saveDepartmentRep(StaffViewModel newDR) { if (newDR == null) { return(false); } string userId = User.Identity.GetUserId(); Staff s1 = StaffDepartmentDAO.GetStaffByUserId(userId); if (s1 == null) { return(false); } bool bRes = StaffDepartmentDAO.changeDR(s1.staffId, newDR.staffId); return(bRes); }
public List <StaffViewModel> FindPossibleDRList() { string userId = User.Identity.GetUserId(); var s1 = StaffDepartmentDAO.GetStaffByUserId(userId); // find the possible DR candidate List <Staff> staffList = StaffDepartmentDAO.FindPossibleDRList(s1); // convert to plain data var svms = new List <StaffViewModel>(); if (staffList != null) { foreach (var s in staffList) { var svm = StaffDepartmentDAO.staffViewModelConverter(s); svms.Add(svm); } } return(svms); }
public ActionResult ApproveReject(string remarks, int?approveSelected, int?rejectSelected) { string userId = User.Identity.GetUserId(); var s1 = StaffDepartmentDAO.GetStaffByUserId(userId); // If reject request is submitted if (rejectSelected != null) { RequestDAO.RejectRequest(rejectSelected, remarks); return(RedirectToAction("ApproveReject")); } else if (approveSelected != null) { RequestDAO.ApproveRequest(approveSelected, remarks); return(RedirectToAction("ApproveReject")); } else { return(View("~/Views/Shared/Error.cshtml")); } }
public ActionResult DepartmentCart(List <RequestViewModel> Model, int?requestId, string btn_itemNo) { ViewBag.requestId = requestId; if (!ModelState.IsValid) { return(View(Model)); } // Get current staff string userId = User.Identity.GetUserId(); var s1 = StaffDepartmentDAO.GetStaffByUserId(userId); #region delete button click if (btn_itemNo != null) { if (Model == null || Model.Count == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } else { switch (requestId) { // First time raise the request case null: var i1 = Model.Where(x => x.itemNo == btn_itemNo).First(); Model.Remove(i1); ModelState.Clear(); Session["cartItems"] = Model.Select(x => x.itemNo).ToList(); return(View(Model)); default: var reqDetail = new RequestViewModel() { requestId = requestId, itemNo = btn_itemNo }; RequestDAO.DeleteRequestDetail(reqDetail); var reqDetails = RequestDAO.GetRequestViewModelListByReqId((int)requestId); ModelState.Clear(); return(View(reqDetails)); } } } #endregion #region submit button click if (Model == null || Model.Count == 0) { return(View()); } bool bRes = false; switch (requestId) { // First time raise the request case null: //if (Model != null && Model.Count > 0) //{ // Model[0].staffId = s1.staffId; // Model[0].departmentId = s1.departmentId; //} bRes = RequestDAO.RaiseRequest(s1.staffId, s1.departmentId, Model); if (bRes) { // Clear the session value Session["cartItems"] = null; } break; // Existed request default: bRes = RequestDAO.UpdateRequestDetails(Model); break; } if (bRes) { return(RedirectToAction("list")); } else { return(View("~/Views/Shared/Error.cshtml")); } #endregion }
public ActionResult Login(string returnUrl) { ViewBag.ReturnUrl = returnUrl; StaffDepartmentDAO.CheckAllTempDH(); return(View()); }
public ActionResult TrendAnalysisReport() { string userId = User.Identity.GetUserId(); var s1 = StaffDepartmentDAO.GetStaffByUserId(userId); var department = s1.departmentId; switch (department) { case ("ARTS"): { return(RedirectToAction("ArtsReport")); } case ("BUSN"): { return(RedirectToAction("BusinessReport")); } case ("COMM"): { return(RedirectToAction("CommerceReport")); } case ("CPSC"): { return(RedirectToAction("ComputerScienceReport")); } case ("ENGL"): { return(RedirectToAction("EnglishReport")); } case ("FINA"): { return(RedirectToAction("FinanceReport")); } case ("MATH"): { return(RedirectToAction("MathematicReport")); } case ("MEDC"): { return(RedirectToAction("MedicineReport")); } case ("REGR"): { return(RedirectToAction("RegistrarReport")); } case ("ZOOL"): { return(RedirectToAction("ZoologyReport")); } default: { return(View("~/Views/Shared/Error.cshtml")); } } }