public static List <ReliefRequisitionViewModel> BindRequisitionViewModel(List <ReliefRequisition> reliefRequisitions) { var reliefRequisitionViewModels = new List <ReliefRequisitionViewModel>(); foreach (var reliefRequisition in reliefRequisitions) { var reliefRequisitionViewModel = new ReliefRequisitionViewModel(); reliefRequisitionViewModel.RequisitionNo = reliefRequisition.RequisitionNo; reliefRequisitionViewModel.RequestedDate = (DateTime)reliefRequisition.RequestedDate; reliefRequisitionViewModel.Status = reliefRequisition.Status.ToString(); reliefRequisitionViewModels.Add(reliefRequisitionViewModel); } return(reliefRequisitionViewModels); }
public static ReliefRequisitionViewModel BindReliefRequisitionViewModel(ReliefRequisition reliefRequisition, List <WorkflowStatus> statuses, string datePref) { var requisition = new ReliefRequisitionViewModel(); requisition.ProgramID = reliefRequisition.ProgramID; requisition.Program = reliefRequisition.Program.Name; requisition.Region = reliefRequisition.AdminUnit.Name; requisition.RequisitionNo = reliefRequisition.RequisitionNo; requisition.RegionID = reliefRequisition.RegionID; requisition.RegionalRequestID = reliefRequisition.RegionalRequestID; if (reliefRequisition.RequestedDate.HasValue) { requisition.RequestedDateEt = reliefRequisition.RequestedDate.Value.ToCTSPreferedDateFormat(datePref); } //); requisition.Round = reliefRequisition.Round; requisition.Status = statuses.Find(t => t.WorkflowID == (int)WORKFLOW.RELIEF_REQUISITION && t.StatusID == reliefRequisition.Status.Value).Description; requisition.RequestedDate = reliefRequisition.RequestedDate.Value; requisition.StatusID = reliefRequisition.Status; requisition.RequisitionID = reliefRequisition.RequisitionID; requisition.CommodityID = reliefRequisition.CommodityID; requisition.ZoneID = reliefRequisition.ZoneID; requisition.Zone = reliefRequisition.AdminUnit1.Name; requisition.Commodity = reliefRequisition.Commodity.Name; requisition.Month = RequestHelper.MonthName(reliefRequisition.Month); requisition.RequestRefNo = reliefRequisition.RegionalRequest != null ? reliefRequisition.RegionalRequest.ReferenceNumber : "Transfer/Swap Requisition"; if (reliefRequisition.RationID != null && reliefRequisition.RationID > 0) { requisition.RationID = (int)reliefRequisition.RationID; } else if (reliefRequisition.RegionalRequest != null && reliefRequisition.RegionalRequest.Ration != null) { requisition.Ration = reliefRequisition.RegionalRequest.Ration.RefrenceNumber; requisition.RationID = reliefRequisition.RegionalRequest.RationID; } return(requisition); }
public ActionResult Requisition_Update([DataSourceRequest] DataSourceRequest request, ReliefRequisitionViewModel reliefRequisitionViewModel) { if (reliefRequisitionViewModel != null && ModelState.IsValid) { var target = _reliefRequisitionService.FindById(reliefRequisitionViewModel.RequisitionID); if (target != null) { target.RequisitionNo = reliefRequisitionViewModel.RequisitionNo; _reliefRequisitionService.EditReliefRequisition(target); } } return(Json(new[] { reliefRequisitionViewModel }.ToDataSourceResult(request, ModelState))); }