// GET: Requisition public ActionResult Index() { var requistionViewModel = new RequisitionViewModel() { Items = itemService.GetAll(), Requisitions = requisitionService.GetAll() .Where(x => x.DepartmentId == User.Identity.GetDepartmentId()) .OrderByDescending(r => r.createdDateTime) .OrderBy(r => r.Status) }; return(View("Index", requistionViewModel)); }
private async Task <IActionResult> GetAllRequisitions(DatatableParametersViewModel dataTableParameters) { try { var result = await _requisitionService.GetAll(_mapper.Map <DatatableParametersDto>(dataTableParameters)); return(Ok(result)); } catch (Exception e) { return(StatusCode(500, new JsonResult(new { message = $"Something went wrong inside the getall requisitions action: {e.Message}" }))); } }
private string generateReqNum(RequisitionModel model) { var currentDocument = service.GetAll(AuthenticationHelper.CompanyId.Value, SessionHelper.SOBId).OrderByDescending(rec => rec.Id).FirstOrDefault(); string newDocNo = ""; if (currentDocument != null) { int outVal; bool isNumeric = int.TryParse(currentDocument.RequisitionNo, out outVal); if (isNumeric && currentDocument.RequisitionNo.Length == 8) { newDocNo = (int.Parse(currentDocument.RequisitionNo) + 1).ToString(); return(newDocNo); } } //Create New DocNum.. string yearDigit = model.RequisitionDate.ToString("yy"); string monthDigit = model.RequisitionDate.ToString("MM"); string docNo = int.Parse("1").ToString().PadLeft(4, '0'); return(yearDigit + monthDigit + docNo); }
public ActionResult Index() { try { var userId = User.Identity.GetUserId(); // Retrieve delegations for user where the status is active var delegations = departmentDelegationService.GetAll() .Where(x => x.UserId == userId) .Where(x => x.Status == CustomStatus.isActive).ToList(); if (delegations != null) { foreach (var item in delegations) { DateRangeHelper dateRangeHelper = new DateRangeHelper(item.StartDate, item.EndDate); ApplicationDbContext context = new ApplicationDbContext(); var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context)); //Check if the delegation period is now bool check = dateRangeHelper.Includes(DateTime.Now); if (check) { userManager.AddToRole(userId, "DepartmentHead"); } else { userManager.RemoveFromRole(userId, "DepartmentHead"); } } } } catch (Exception) { } if (User.IsInRole("StoreClerk") || User.IsInRole("StoreManager") || User.IsInRole("StoreSupervisor")) { var purchaseOrderCount = purchaseOrderService.GetAll().Where(po => po.Status == CustomStatus.PendingApproval).Count(); ViewBag.Poc = purchaseOrderCount; var stockAdjustmentCount = stockAdjustmentService.GetAll().Where(sa => sa.Status == CustomStatus.PendingApproval).Count(); ViewBag.Sac = stockAdjustmentCount; var disbursementCount = disbursementService.GetAll().Where(x => x.Status == CustomStatus.ForRetrieval).Count(); ViewBag.D = disbursementCount; var itemCount = itemService.GetItemsLowerThanReorderLevel().Count(); ViewBag.I = itemCount; dynamic viewModel = new ItemViewModel() { Items = itemService.GetAll() }; return(View("Index", viewModel)); } if (User.IsInRole("Employee") || User.IsInRole("DepartmentHead") || User.IsInRole("Representative")) { var requisitionCount = requisitionService.GetAll() .Where(x => x.DepartmentId == User.Identity.GetDepartmentId()) .Where(r => r.Status == CustomStatus.PendingApproval).Count(); ViewBag.R = requisitionCount; var collectionCount = itemDisbursementService.GetDepartmentCollection(User.Identity.GetDepartmentId()).Count(); ViewBag.C = collectionCount; var activeDelegationCount = departmentDelegationService.GetAll().Where(x => x.DepartmentId == User.Identity.GetDepartmentId()).Where(x => x.Status == CustomStatus.isActive).Count(); ViewBag.adC = activeDelegationCount; var pendingDelegationCount = departmentDelegationService.GetAll().Where(x => x.DepartmentId == User.Identity.GetDepartmentId()).Where(x => x.Status == CustomStatus.isNotActive).Where(x => x.StartDate > DateTime.Now).Count(); ViewBag.pdC = pendingDelegationCount; dynamic requistionViewModel = new RequisitionViewModel() { Items = itemService.GetAll(), Requisitions = requisitionService.GetAll() .Where(x => x.DepartmentId == User.Identity.GetDepartmentId()) .OrderByDescending(r => r.createdDateTime) .OrderByDescending(r => r.Status) }; return(View("Index", requistionViewModel)); } return(View()); }