public ActionResult GetPsnpRequisitions() { var requests = _reliefRequisitionService.GetAllReliefRequisition().OrderByDescending(t => t.RequestedDate).Take(5); var r = new List<PSNPRequisitionViewModel>(); foreach (var regionalRequsition in requests) { var f = new PSNPRequisitionViewModel(); f.Number = regionalRequsition.RequisitionNo; f.Commodity = regionalRequsition.Commodity.Name; f.Beneficicaries = regionalRequsition.ReliefRequisitionDetails.Sum(t => t.BenficiaryNo); f.Amount = regionalRequsition.ReliefRequisitionDetails.Sum(t => t.Amount); f.Status = regionalRequsition.Status; r.Add(f); } return Json(r, 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); }