private async void DoMoveToDelivery(object obj) { try { WorkInProgress = true; if (BatchTans != null && SelectedTans != null && SelectedTans.Count() > 0) { var InValidTans = SelectedTans.Where(t => (((BatchTanVM)t).TanState.HasValue && S.UnDelivarableTanStates.Contains(((BatchTanVM)t).TanState.Value)) || ((BatchTanVM)t).IsDoubtRaised.ToLower().Equals("true")).ToList(); if (InValidTans.Any()) { AppInfoBox.ShowInfoMessage("Selected Tan Contains NotAssigned/Curation In progress/Doubt Raised tans."); return; } if (DeliveryBatch != null) { var moveTansDto = new MoveTansDTO(); moveTansDto.TanIds = SelectedTans.Select(t => ((BatchTanVM)t).Id).ToList(); moveTansDto.TargetCategory = DeliveryBatch.Id; var status = await RestHub.MoveToDelivery(moveTansDto); if (status.HttpCode == System.Net.HttpStatusCode.OK) { SearchTans.Execute(this); var result = MessageBox.Show(status.StatusMessage, "Status", MessageBoxButton.OKCancel); } else { AppErrorBox.ShowErrorMessage("Can't Move TANs To Delivery . .", status.HttpResponse); } } else { AppInfoBox.ShowInfoMessage("Delivery Batch Not Selected."); } } else { AppInfoBox.ShowInfoMessage("Please Load and Select TANs To Proceed . ."); } WorkInProgress = false; } catch (Exception ex) { Log.This(ex); AppErrorBox.ShowErrorMessage("Can't Move TANs To Delivery . .", ex.ToString()); } finally { WorkInProgress = false; } }
public string MoveTansToCategory(MoveTansDTO moveTansDto) { using (TransactionScope scope = new TransactionScope()) using (var db = new ApplicationDbContext()) { var tansToMove = db.Tans.Include("Batch").Where(t => moveTansDto.TanIds.Contains(t.Id)).ToList(); foreach (var tan in tansToMove) { tan.TanCategory = (TanCategory)moveTansDto.TargetCategory; } db.SaveChanges(); scope.Complete(); return($"{tansToMove.Count} Tans Moved Successfully"); } }
private async void DoMoveToCategory(object obj) { try { WorkInProgress = true; if (BatchTans != null && SelectedTans != null && SelectedTans.Count() > 0) { if (FromBatch != null && ToCategory != null) { var moveTansDto = new MoveTansDTO(); moveTansDto.TanIds = SelectedTans.Select(t => ((BatchTanVM)t).Id).ToList(); moveTansDto.TargetCategory = ToCategory.Value; var status = await RestHub.MoveToCategory(moveTansDto); if (status.HttpCode == System.Net.HttpStatusCode.OK) { SearchTans.Execute(this); var result = MessageBox.Show(status.StatusMessage, "Status", MessageBoxButton.OKCancel); } else { AppErrorBox.ShowErrorMessage("Can't Move TANs To Category . .", status.HttpResponse); } } else { AppInfoBox.ShowInfoMessage("From Batch, To Category Should Be Selected, And Must Be Different To Proceed. ."); } } else { AppInfoBox.ShowInfoMessage("Please Load and Select TANs To Proceed . ."); } } catch (Exception ex) { Log.This(ex); AppErrorBox.ShowErrorMessage("Can't Move TANs To Category . .", ex.ToString()); } finally { WorkInProgress = false; } }
public string MoveTansToDelivery(MoveTansDTO moveTansDto) { using (TransactionScope scope = new TransactionScope()) using (var db = new ApplicationDbContext()) { var tans = db.Tans.Include("Batch").Where(t => moveTansDto.TanIds.Contains(t.Id)).ToList(); var DeliveryBatch = db.DeliveryBatches.Where(t => t.Id == moveTansDto.TargetCategory).FirstOrDefault(); if (DeliveryBatch != null) { DeliveryBatch.Tans = tans; } //var tansToMove = db.Tans.Include("Batch").Where(t => moveTansDto.TanIds.Contains(t.Id)).ToList(); //foreach (var tan in tansToMove) // tan.DeliveryBatchId = moveTansDto.TargetCategory; db.SaveChanges(); scope.Complete(); return($"{tans.Count} Tans Moved Successfully"); } }
public static async Task <RestStatus> MoveToDelivery(MoveTansDTO moveTansDto) { try { RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent(String.Empty); HttpResponseMessage response = await httpClient.PostAsync(MOVE_TO_DELIVERY, new StringContent(JsonConvert.SerializeObject(moveTansDto), Encoding.UTF8, "application/json")); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { status.HttpCode = System.Net.HttpStatusCode.OK; status.StatusMessage = responseText; } else { status.StatusMessage = responseText; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public object MoveToDelivery(MoveTansDTO moveTansDto) { return(ShipmentService.MoveTansToDelivery(moveTansDto)); }