public async Task <ActionResult> Delete([FromRoute] int id, [FromBody] InvoiceDelete invoiceDelete) { try { var grain = _orleansService.Client.GetGrain <InvoiceDeleteCommand>(0); var result = await grain.InvoiceDelete(invoiceDelete); if (result.__CQRSSuccessful) { return new ContentResult() { StatusCode = 200 } } ; else { return(new ContentResult() { StatusCode = result.__CQRSStatusCode, Content = result.__CQRSErrorMessage, ContentType = "text/plain" }); } } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(new ContentResult() { StatusCode = 500, Content = "Fatal API Error", ContentType = "text/plain" }); } }
public void GetXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <function controlid=""unittest""> <delete_invoice key=""1234"" /> </function>"; Stream stream = new MemoryStream(); XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Encoding = Encoding.UTF8; xmlSettings.Indent = true; xmlSettings.IndentChars = " "; IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings); InvoiceDelete record = new InvoiceDelete("unittest"); record.RecordNo = 1234; record.WriteXml(ref xml); xml.Flush(); stream.Position = 0; StreamReader reader = new StreamReader(stream); Diff xmlDiff = DiffBuilder.Compare(expected).WithTest(reader.ReadToEnd()) .WithDifferenceEvaluator(DifferenceEvaluators.Default) .Build(); Assert.IsFalse(xmlDiff.HasDifferences(), xmlDiff.ToString()); }
public async System.Threading.Tasks.Task Delete(data.InvoiceContext db, InvoiceDelete delete) { try { var invoiceToDelete = await db.Invoices.FirstOrDefaultAsync(w => w.InvoiceId == delete.InvoiceId); db.Invoices.Remove(invoiceToDelete); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); } }
public void GetXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <function controlid=""unittest""> <delete_invoice key=""1234"" /> </function>"; InvoiceDelete record = new InvoiceDelete("unittest") { RecordNo = 1234 }; this.CompareXml(expected, record); }
// Delete Transaction Code public async System.Threading.Tasks.Task Delete(InvoiceDelete delete) { try { using (var db = new data.InvoiceContext()) { await Delete(db, delete); await db.SaveChangesAsync(); } } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); } }
public static void RunInvoiceDelete(ref Web AretVal) { AretVal = new InvoiceDelete(); }
public async Task<byte[]> InvoiceDelete(InvoiceDelete.request request, CancellationToken? token = null) { return await GetBytesAsync(request.ToXmlString(), token.GetValueOrDefault(CancellationToken.None)); }