public JsonResult ImportantNumbers(string id, string requestName) { if (string.IsNullOrEmpty(requestName)) { var requests = _reliefRequisitionService.GetAllReliefRequisition() .Where(d => d.AdminUnit.Name == id) .GroupBy(s => s.Status) .Select(c => new { Status = c.Key, Count = c.Count(), }); return(Json(requests, JsonRequestBehavior.AllowGet)); } else { var request = _reliefRequisitionService.GetAllReliefRequisition() .Where(d => d.AdminUnit.Name == id && d.Program.Name == requestName) .GroupBy(s => s.Status) .Select(c => new { Status = c.Key, Count = c.Count(), }); return(Json(request, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetPsnpRequisitions() { var requests = _reliefRequisitionService.GetAllReliefRequisition().OrderByDescending(t => t.RequestedDate); var r = new List <PSNPRequisitionViewModel>(); foreach (var regionalRequsition in requests) { var psnpReqistions = new PSNPRequisitionViewModel { Number = regionalRequsition.RequisitionNo, Commodity = regionalRequsition.Commodity.Name, Beneficicaries = regionalRequsition.ReliefRequisitionDetails.Sum(t => t.BenficiaryNo), Amount = regionalRequsition.ReliefRequisitionDetails.Sum(t => t.Amount), Status = regionalRequsition.Status, RequisitionId = regionalRequsition.RequisitionID }; if (regionalRequsition.RegionalRequest != null) { psnpReqistions.PlanId = regionalRequsition.RegionalRequest.PlanID; psnpReqistions.PlanName = regionalRequsition.RegionalRequest.Plan.PlanName; } r.Add(psnpReqistions); } return(Json(r, JsonRequestBehavior.AllowGet)); }