public ActionResult Approve() { string token = GetToken(); List <AdjustmentModel> adjlist = new List <AdjustmentModel>(); List <AdjustmentDetailModel> adjdetail = new List <AdjustmentDetailModel>(); SupplierItemModel supp = new SupplierItemModel(); try { //get pending status adjustments adjlist = APIAdjustment.GetAdjustmentByStatus(token, ConAdjustment.Active.PENDING, out string error); if (adjlist != null) { foreach (AdjustmentModel ad in adjlist) { //to divide according to raised to user role ad.RaiseToRole = (APIUser.GetUserByUserID((int)ad.Raisedto, token, out error)).Role; foreach (AdjustmentDetailModel adj in ad.Adjds) { try { //to show each item adjusted price and total pirce of adjustment form supp = APISupplier.GetOneSupplierItemByItemId(adj.Itemid, token, out error); adj.Price = supp.Price * Math.Abs(adj.Adjustedqty); ad.TotalPrice += adj.Price; } catch (Exception) { if (supp == null) { ad.TotalPrice += 0; } } } } //separate adjustment pending list by reported to roles (supervisor/manager) ViewBag.manager = adjlist.Where(x => x.RaiseToRole == ConUser.Role.MANAGER).ToList(); adjlist = adjlist.Where(x => x.RaiseToRole == ConUser.Role.SUPERVISOR).ToList(); } else { adjlist = new List <AdjustmentModel>(); ViewBag.manager = adjlist; } } catch (Exception ex) { RedirectToAction("Index", "Error", new { error = ex.Message }); } return(View(adjlist)); }
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 })); } }