public ActionResult SearchPreviousDelegation(EditDelegationViewModel viewmodel, int id) { string token = GetToken(); UserModel um = GetUser(); DelegationModel um1 = new DelegationModel(); try { if (viewmodel != null) { viewmodel.assignedby = um.Userid; um1.Delid = id; DelegationModel um2 = APIDelegation.GetDelegationByDeleid(token, id, out string delerror); um1.Startdate = um2.Startdate; um1.Enddate = viewmodel.EndDate; um1.Userid = um2.Userid; um1.AssignedbyId = um.Userid; um1.Active = ConDelegation.Active.ACTIVE; APIDelegation.UpdateDelegation(token, um1, out string error); } } catch (Exception ex) { return(RedirectToAction("Index", "Error", new { error = ex.Message })); } Session["noti"] = true; Session["notitype"] = "success"; Session["notititle"] = "Update Delegation"; Session["notimessage"] = "Delegation is updated successfully"; return(RedirectToAction("SearchPreviousDelegation")); }
public ActionResult CreateDelegationList(CreateDelegationViewModel viewmodel, int userid) { string token = GetToken(); UserModel um = GetUser(); DelegationModel dm = new DelegationModel(); try { if (viewmodel != null) { viewmodel.assignedby = um.Userid; dm.Userid = userid; dm.Enddate = (DateTime)viewmodel.EndDate; dm.Startdate = (DateTime)viewmodel.StartDate; dm.AssignedbyId = viewmodel.assignedby; dm = APIDelegation.CreateDelegation(token, dm, out string error); } } catch (Exception ex) { return(RedirectToAction("Index", "Error", new { error = ex.Message })); } Session["noti"] = true; Session["notitype"] = "success"; Session["notititle"] = "Delegation"; Session["notimessage"] = dm.Username + " is Delegated as Head of Department"; return(RedirectToAction("SearchPreviousDelegation")); }
public JsonResult CancelDelegation(int id) { string token = GetToken(); UserModel um = GetUser(); bool result = false; if (id != 0) { DelegationModel dm = APIDelegation.GetDelegationByDeleid(token, id, out string error); DelegationModel dm1 = APIDelegation.CancelDelegation(token, dm, out string cancelerror); result = true; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult SearchPreviousDelegation() { string token = GetToken(); UserModel um = GetUser(); DelegationModel reqms = new DelegationModel(); EditDelegationViewModel viewmodel = new EditDelegationViewModel(); UserModel DelegatedUser = new UserModel(); try { reqms = APIDelegation.GetPreviousDelegationByDepid(token, um.Deptid, out string error); ViewBag.Userid = reqms.Userid; ViewBag.name = reqms.Username; ViewBag.StartDate = reqms.Startdate; ViewBag.Enddate = reqms.Enddate; ViewBag.Deleid = reqms.Delid; if (reqms.Userid == 0 || reqms == null) { ViewBag.name = ""; } else { DelegatedUser = APIUser.GetUserByUserID(reqms.Userid, token, out error); if (DelegatedUser != null && DelegatedUser.Userid != 0) { ViewBag.name = DelegatedUser.Fullname; } } } catch (Exception ex) { return(RedirectToAction("Index", "Error", new { error = ex.Message })); } return(View(viewmodel)); }
public ActionResult Index() { string error = ""; string token = GetToken(); UserModel um = GetUser(); List <RequisitionModel> reqs = new List <RequisitionModel>(); UserModel CurrentRep = new UserModel(); DepartmentCollectionPointModel CurrentCP = new DepartmentCollectionPointModel(); DelegationModel CurrentTemp = new DelegationModel(); UserModel CurrentTempUser = new UserModel(); try { reqs = APIRequisition.GetRequisitionByStatus(ConRequisition.Status.PENDING, token, out error); ViewBag.ReqCount = 0; ViewBag.ReqCount = reqs.Where(x => x.Depid == um.Deptid).Count(); ViewBag.DelegationType = "Temporary HOD"; CurrentRep = APIUser.GetUserByRoleAndDeptID(ConUser.Role.DEPARTMENTREP, um.Deptid, token, out error).FirstOrDefault(); ViewBag.RepName = CurrentRep.Fullname; if (ViewBag.RepName == null) { ViewBag.RepName = "None"; } CurrentCP = APICollectionPoint.GetActiveDepartmentCollectionPointByDeptID(token, um.Deptid, out error); ViewBag.CollectionPoint = CurrentCP.CpName; if (ViewBag.CollectionPoint == null) { ViewBag.CollectionPoint = "None"; } CurrentTemp = APIDelegation.GetPreviousDelegationByDepid(token, um.Deptid, out error); if (CurrentTemp.Delid != 0) { CurrentTempUser = APIUser.GetUserByUserID(CurrentTemp.Userid, token, out error); ViewBag.TempHOD = CurrentTempUser.Fullname; ViewBag.TempDate = CurrentTemp.Startdate.Value.ToShortDateString() + " - " + CurrentTemp.Enddate.Value.ToShortDateString(); if (CurrentTemp.Startdate <= DateTime.Today && DateTime.Today <= CurrentTemp.Enddate) { ViewBag.DelegationType = "Current Temporary HOD"; } else { ViewBag.DelegationType = "Upcoming Temporary HOD"; } } if (CurrentTemp.Delid == 0 || ViewBag.TempHOD == null) { ViewBag.DelegationType = "Temporary HOD"; ViewBag.TempHOD = "None"; ViewBag.TempDate = "-"; } return(View()); } catch (Exception ex) { return(RedirectToAction("Index", "Error", new { error = ex.Message })); } }