public async Task ProcessAsync(InvoiceConfirmation invoiceConfirmation) { string data = _xmlSerializer.Serialize(invoiceConfirmation); _log.Info("Sending data starting", new { data }); HttpResponseMessage response; try { var content = new StringContent(data, Encoding.UTF8, "text/xml"); response = await HttpClient.PostAsync(_url, content); } catch (Exception ex) { _log.Error(ex, null, new { InvoiceConfirmation = data }.ToJson()); throw; } if (!response.IsSuccessStatusCode) { string responseContent = await response.Content.ReadAsStringAsync(); var exception = new InvoiceConfirmationException("Invoice confirmation post failed.") { StatusCode = response.StatusCode, Content = responseContent }; _log.Error(exception, null, new { StatusCode = response.StatusCode, Content = responseContent, InvoiceConfirmation = data }.ToJson()); throw exception; } _log.Info("Data successfully sent", new { data }); await _repository.AddAsync(invoiceConfirmation); }
protected override void OnNavigatedTo(NavigationEventArgs e) { if ((bool)PhoneApplicationService.Current.State.ContainsKey("isTombStoned")) { base.OnNavigatedTo(e); return; } if (this.Source == Source.EXTERNAL) { base.OnNavigatedTo(e); return; } if (Source == Model.Base.Source.LINE_ITEM_MULTI_ADJUST || Source == Model.Base.Source.LINE_ITEM_MULTI_REJECT) { InvoiceConfirmation invConfirmation = new InvoiceConfirmation(); invConfirmation.ConfirmationItems = GetLineItemConfirmationItems(LineItemInputDetails.SelectedLineItems); invConfirmation.TotalNetAmount = LineItemInputDetails.NetAmount; invConfirmation.ConfirmationTitle = Source == Model.Base.Source.LINE_ITEM_MULTI_ADJUST ? "Adjust (" + invConfirmation.ConfirmationItems.Count + ")" : "Reject (" + invConfirmation.ConfirmationItems.Count + ")"; this.DataContext = invConfirmation; } else if (Source == Model.Base.Source.INVOICE_MULTI_APPROVE || Source == Model.Base.Source.INVOICE_MULTI_REJECT) { InvoiceConfirmation invConfirmation = new InvoiceConfirmation(); invConfirmation.ConfirmationItems = GetConfirmationItems(InvoiceInputDetails.SelectedInvoices); invConfirmation.TotalNetAmount = InvoiceInputDetails.NetTotal; invConfirmation.ConfirmationTitle = Source == Model.Base.Source.INVOICE_MULTI_APPROVE ? "Approve (" + invConfirmation.ConfirmationItems.Count + ")" : "Reject (" + invConfirmation.ConfirmationItems.Count + ")"; this.DataContext = invConfirmation; } base.OnNavigatedTo(e); }
private Task ProcessMessageAsync(InvoiceConfirmation message) { return(_service.ProcessAsync(message)); }