public async Task <IActionResult> PostOrder() { var sw = Stopwatch.StartNew(); var order = InvoiceOrder.Create("ProffOFConcept", Guid.NewGuid(), "OrderNumber", "TransportNumber"); order.SetSite("Site"); order.SetArrived(DateTime.Now.Date); order.SetAutomaticInvoicingAllowed(); order.UpdateCountryOfArrival("MKD"); order.UpdateCountryOfDeparture("BE"); order.UpdateCustomer("KTN"); order.UpdateHaulier("DHL"); order.UpdateOrderDate(DateTime.Now.Date); AddProperties(order); AddStockLines(order); AddActions(order); _invoicingContext.InvoiceOrders.AddRange(order); sw.Stop(); var timeSpentOrderCreate = sw.ElapsedMilliseconds; sw = Stopwatch.StartNew(); await _invoicingContext.SaveChangesAsync(); var timeSpentOrderSave = sw.ElapsedMilliseconds; sw.Stop(); return(Ok($"Cost of Order Creation is: {timeSpentOrderCreate} Milliseconds\nSaving to db with EF.Core 3.1 is: {timeSpentOrderSave} Milliseconds\nTotal Response Time is: {timeSpentOrderCreate + timeSpentOrderSave}")); }
public async Task ReturnAllInvoiceOrdersJson() { // GIVEN var order1 = InvoiceOrder.Create("Plato", Guid.NewGuid(), "ICLX000020", "TRP001"); order1.UpdateCustomer(Guid.NewGuid(), "TestCustomer1"); order1.UpdateOrderDate(new DateTime(2019, 03, 15)); order1.UpdateOrderType("Inbound"); order1.SetSite("Lb1227"); var order2 = InvoiceOrder.Create("Plato", Guid.NewGuid(), "ICLX000020", "TRP002"); order1.UpdateCustomer(Guid.NewGuid(), "TestCustomer1"); order2.UpdateOrderDate(new DateTime(2019, 02, 15)); order2.UpdateOrderType("Inbound"); order2.SetSite("Lb1227"); var action1 = order1.AddAction("Action1"); var action2 = order1.AddAction("Action2"); var action3 = order1.AddAction("Action3"); var action4 = order2.AddAction("Action1"); var action5 = order2.AddAction("Action2"); var action6 = order2.AddAction("Action3"); var property1 = order1.AddProperties("property1", "PropertyValue1"); var property2 = order1.AddProperties("property2", "PropertyValue2"); var property3 = order1.AddProperties("property3", "PropertyValue3"); var property4 = order2.AddProperties("property1", "PropertyValue1"); var property5 = order2.AddProperties("property2", "PropertyValue2"); var property6 = order2.AddProperties("property3", "PropertyValue3"); for (int i = 1; i <= 10; i++) { action1.AddProperty(Guid.NewGuid(), "string", $"name{i}", "$value{i}"); action2.AddProperty(Guid.NewGuid(), "string", $"name{i}", "$value{i}"); action3.AddProperty(Guid.NewGuid(), "string", $"name{i}", "$value{i}"); action4.AddProperty(Guid.NewGuid(), "string", $"name{i}", "$value{i}"); action5.AddProperty(Guid.NewGuid(), "string", $"name{i}", "$value{i}"); action6.AddProperty(Guid.NewGuid(), "string", $"name{i}", "$value{i}"); } await InsertAsync(order1); await InsertAsync(order2); // WHEN var response = await Client.GetAsync("/api/invoice-orders/AllOrdersJson"); // THEN response.StatusCode.Should().Be(HttpStatusCode.OK, response.Content.ReadAsStringAsync().Result); var result = JsonConvert.DeserializeObject <IEnumerable <InvoiceOrder> >(response.Content.ReadAsStringAsync().Result); using (new AssertionScope()) { result.Should().HaveCount(2); } }
private void AddProperties(InvoiceOrder order) { for (int i = 0; i < row; i++) { var property = Property.Create($"name{i}", $"Value{i}"); order.SetProperty(property); } }
private void AddActions(InvoiceOrder order) { for (int i = 0; i < row; i++) { var action = Action.Create($"prodict{i}"); AddActionProperty(action); order.AddAction(action); } }
private void AddStockLines(InvoiceOrder order) { for (int i = 0; i < 20; i++) { var stockLine = StockLine.Create($"prodict{i}"); AddStockLineProperty(stockLine); AddStockLineAction(stockLine); order.AddStockLine(stockLine); } }
public IActionResult GetInvoice(int id) { InvoiceOrder getInvoiceById = new InvoiceOrder { Invoice = invoiceManager.GetById(id), InvoiceProducts = invoiceProductManager.GetAllInclude(p => p.Product).Where(i => i.InvoiceId == id).ToList() }; return(Ok(getInvoiceById)); }
private InvoiceOrder ToEntity(CreateInvoiceOrderModel createInvoiceOrderModel, IEnumerable <PropertyType> propertyTypes) { var order = InvoiceOrder.Create(createInvoiceOrderModel.Application, Guid.Empty, createInvoiceOrderModel.OrderNumber, createInvoiceOrderModel.TransportNumber); order.UpdateOrderType(createInvoiceOrderModel.OrderType); order.UpdateCustomer(createInvoiceOrderModel.CustomerId, createInvoiceOrderModel.CustomerCode); order.UpdateOrderDate(createInvoiceOrderModel.Date); order.SetSite(createInvoiceOrderModel.Site); AddActions(order); AddStockLines(order); AddProperties(order); return(order); }
public IActionResult CreateInvoice(InvoiceOrder invoiceOrder) { if (!ModelState.IsValid || invoiceOrder.InvoiceProducts.Count() == 0) { return(BadRequest()); } foreach (InvoiceProducts product in invoiceOrder.InvoiceProducts) { product.Invoice = invoiceOrder.Invoice; } invoiceOrder.Invoice.Date = DateTime.UtcNow; UpdateProducts(invoiceOrder.InvoiceProducts); invoiceManager.AddInvoice(invoiceOrder.Invoice, invoiceOrder.InvoiceProducts); invoiceManager.Complete(); return(Ok(invoiceOrder.Invoice)); }
public static Task <IEnumerable <Invoice> > GetInvoicesAsync(this FreeAgentClient client, InvoiceViewFilter invoiceFilter = null, InvoiceOrder orderBy = InvoiceOrder.CreatedAt) { var view = invoiceFilter ?? InvoiceViewFilter.RecentOpenOrOverdue(); var sort = orderBy.GetMemberValue(); return(client.GetOrCreateAsync(c => c.InvoiceList(client.Configuration.CurrentHeader, view.FilterValue, sort), r => r.Invoices)); }