public void CreateOrder(OrderDto orderDto, List <OrderLineDto> orderLineDtoList) { CreateOrder(orderDto); foreach (OrderLineDto orderLineDto in orderLineDtoList) { orderLineDto.Orderid = orderDto.Orderid; OrderLineData orderLineData = new OrderLineData(orderLineDto); orderLineDto.OrderLineid = orderLineData.CreateRecord(); } LoginData.Stop(); }
public ActionResult CreateOrderAndLines() { try { var accHandle = (AccountHandle)Session["accHandle"]; var session = EcoSession; if (session == null) { return(View("ExampleView")); } //create order using the debtor created before var order = new OrderData { DebtorHandle = EconomicModels.Debtor.Handle, DebtorName = EconomicModels.Debtor.Name, Date = DateTime.Now, CurrencyHandle = EconomicModels.Debtor.CurrencyHandle, TermOfPaymentHandle = EconomicModels.Debtor.TermOfPaymentHandle }; OrderHandle orderHandle = session.Order_CreateFromData(order); var products = EconomicModels.Products; // add items to this order, using the created products var orderLines = new OrderLineData[] { new OrderLineData { ProductHandle = products[0].Handle, Description = products[0].Name, Quantity = 500, OrderHandle = orderHandle, UnitCostPrice = products[0].SalesPrice }, new OrderLineData { ProductHandle = products[1].Handle, Description = products[1].Name, Quantity = 200, OrderHandle = orderHandle, UnitCostPrice = products[1].SalesPrice } }; session.OrderLine_CreateFromDataArray(orderLines); order.Handle = orderHandle; EconomicModels.Order = order; } catch (Exception e) { return(ReturnWithError(e.Message)); } ViewData["message"] = "Order created and orderlines added!"; return(View("ExampleView")); }
public ActionResult CreateOrderAndLines() { try { var accHandle = (AccountHandle)Session["accHandle"]; var session = EcoSession; if (session == null) return View("ExampleView"); //create order using the debtor created before var order = new OrderData { DebtorHandle = EconomicModels.Debtor.Handle, DebtorName = EconomicModels.Debtor.Name, Date = DateTime.Now, CurrencyHandle = EconomicModels.Debtor.CurrencyHandle, TermOfPaymentHandle = EconomicModels.Debtor.TermOfPaymentHandle }; OrderHandle orderHandle = session.Order_CreateFromData(order); var products = EconomicModels.Products; // add items to this order, using the created products var orderLines = new OrderLineData[] { new OrderLineData { ProductHandle = products[0].Handle, Description = products[0].Name, Quantity = 500 , OrderHandle = orderHandle, UnitCostPrice = products[0].SalesPrice }, new OrderLineData { ProductHandle = products[1].Handle, Description = products[1].Name, Quantity = 200 , OrderHandle = orderHandle, UnitCostPrice = products[1].SalesPrice } }; session.OrderLine_CreateFromDataArray(orderLines); order.Handle = orderHandle; EconomicModels.Order = order; } catch (Exception e) { return ReturnWithError(e.Message); } ViewData["message"] = "Order created and orderlines added!"; return View("ExampleView"); }
private void ProcessOrderLineImportRow(string[] pieces, string line, int lineNumber, OrderData order) { var processLine = true; if (order == null) { AddError(line, lineNumber, "No existing Order for line."); processLine = false; } if (pieces.Length < minimumSupportedColumnsForLine) { AddError(line, lineNumber, "Invalid line - too few columns for LINE"); processLine = false; } var productCode = pieces[itemCodeColumn]; int quantity; processLine &= SetIntegerFromString(line, lineNumber, pieces[quantityColumn], out quantity); decimal unitPrice; processLine &= SetDecimalFromString(line, lineNumber, pieces[unitPriceColumn], out unitPrice); if (processLine) { var orderLine = new OrderLineData { Item = new ProductItemData {ItemCode = productCode}, QuantityOrdered = new QuantityData(quantity), UnitPrice = new MonetaryAmountData(unitPrice, CommerceSettings.DefaultCurrency), ExtendedAmount = new MonetaryAmountData(unitPrice*quantity, CommerceSettings.DefaultCurrency) }; order.Lines.Add(orderLine); } }