public List <PurchaseOrderProgressSteps> GetServiceStatus(string id, string service) { lstOfPurchaseOrderProgressSteps = new List <PurchaseOrderProgressSteps>(); string result = GetAsync(id, service).Result; var objResult = JsonConvert.DeserializeObject <PurchaseOrderResult>(result); var group = (from p in objResult.hits.hits.ToList() where p._source.PONumber == id group p by p._source.ThreadID into g select new { ThreadId = g.Key, POResult = g.ToList() }).ToList(); foreach (var item in group) { var poProgressSteps = new PurchaseOrderProgressSteps(); poProgressSteps.PONumber = id; poProgressSteps.ThreadID = item.ThreadId; var status = poStatusResolver.GetPOStatus(item.POResult, service); poProgressSteps.lstOfSteps = poStatusResolver.GetListOfProgressSteps(service, status); lstOfPurchaseOrderProgressSteps.Add(poProgressSteps); } return(lstOfPurchaseOrderProgressSteps); }
private List <ProgressStep> GetSteps(List <Hit> poResult) { List <ProgressStep> result = new List <ProgressStep>(); List <string> allSteps = new List <string> { CONSTANTS.B2BDIRECT, CONSTANTS.SubmittedPO, CONSTANTS.B2BServices, CONSTANTS.GCMP, CONSTANTS.Shipping }; var selected = poResult.Where(x => x._type == CONSTANTS.GCMPServiceStatus).ToList(); var selectedB2BServices = poResult.Where(x => x._type == CONSTANTS.postatusfromb2bservicesstatus).ToList(); var selectedSendPurchaseOrder = poResult.Where(x => x._type == CONSTANTS.sendPurchaseOrderstatus).ToList(); var selectedSubmittedPODetails = poResult.Where(x => x._type == CONSTANTS.submittedpodetailsstatus).FirstOrDefault(); var selectIncomingTransactions = poResult.Where(x => x._type == CONSTANTS.IncomingTransactionsLowerCase).FirstOrDefault(); if (selected != null && selected.Count != 0) { result.Add(new ProgressStep(CONSTANTS.B2BDIRECT, (selectIncomingTransactions != null ? POStatus.Successful : POStatus.NotStarted))); result.Add(new ProgressStep(CONSTANTS.SubmittedPO, (selectedSubmittedPODetails != null) ? POStatus.Successful : POStatus.NotStarted)); result.Add(new ProgressStep(CONSTANTS.B2BServices, (selectedB2BServices != null) ? POStatus.Successful : POStatus.NotStarted)); result.Add(new ProgressStep(CONSTANTS.GCMP, (selected.Any(x => (!string.IsNullOrEmpty(x._source.status)) && x._source.status.Equals("H", StringComparison.OrdinalIgnoreCase)) ? POStatus.Successful : POStatus.InProgess))); result.Add(new ProgressStep(CONSTANTS.Shipping, POStatus.NotStarted)); return(result); } if (selectedB2BServices != null && selectedB2BServices.Count != 0) { result.Add(new ProgressStep(CONSTANTS.B2BDIRECT, POStatus.Successful)); result.Add(new ProgressStep(CONSTANTS.SubmittedPO, POStatus.Successful)); result.Add(new ProgressStep(CONSTANTS.B2BServices, selectedB2BServices.Any(x => (!string.IsNullOrEmpty(x._source.status)) && poStatusResolver.GetPOStatus(x._source.status) == POStatus.Successful) ? POStatus.Successful : POStatus.InProgess)); result.Add(new ProgressStep(CONSTANTS.GCMP, POStatus.NotStarted)); result.Add(new ProgressStep(CONSTANTS.Shipping, POStatus.NotStarted)); return(result); } if (selectedSendPurchaseOrder != null && selectedSendPurchaseOrder.Count != 0) { result.Add(new ProgressStep(CONSTANTS.B2BDIRECT, POStatus.Successful)); result.Add(new ProgressStep(CONSTANTS.SubmittedPO, POStatus.Successful)); result.Add(new ProgressStep(CONSTANTS.B2BServices, POStatus.InProgess)); result.Add(new ProgressStep(CONSTANTS.GCMP, POStatus.NotStarted)); result.Add(new ProgressStep(CONSTANTS.Shipping, POStatus.NotStarted)); return(result); } if (selectedSubmittedPODetails != null) { result.Add(new ProgressStep(CONSTANTS.B2BDIRECT, POStatus.Successful)); result.Add(new ProgressStep(CONSTANTS.SubmittedPO, POStatus.Successful)); result.Add(new ProgressStep(CONSTANTS.B2BServices, POStatus.NotStarted)); result.Add(new ProgressStep(CONSTANTS.GCMP, POStatus.NotStarted)); result.Add(new ProgressStep(CONSTANTS.Shipping, POStatus.NotStarted)); return(result); } result.Add(new ProgressStep(CONSTANTS.B2BDIRECT, POStatus.Successful)); result.Add(new ProgressStep(CONSTANTS.SubmittedPO, POStatus.NotStarted)); result.Add(new ProgressStep(CONSTANTS.B2BServices, POStatus.NotStarted)); result.Add(new ProgressStep(CONSTANTS.GCMP, POStatus.NotStarted)); result.Add(new ProgressStep(CONSTANTS.Shipping, POStatus.NotStarted)); return(result); }