public ActionResult AddOrder(AddOrderViewModel OrderViewModel) { Orders order = new Orders() { CustomerID = OrderViewModel.CustomerID, EmployeeID = OrderViewModel.EmployeeID, OrderDate = DateTime.Now, RequiredDate = DateTime.Now.AddDays(7), ShippedDate = DateTime.Now.AddDays(2), Freight = 20, ShipName = shipperContext.GetShippers().Where(c => c.ShipperID == OrderViewModel.ShipperID).FirstOrDefault().CompanyName, ORDER_DETAILS = new List<Order_Details>(new Order_Details[] { new Order_Details() { ProductID = OrderViewModel.ProductID, Quantity = OrderViewModel.Quantity, UnitPrice = decimal.Parse(productContext.GetProductPriceByProductID(OrderViewModel.ProductID).ToString()), Discount = 1 } }) }; int result = orderContext.AddOrder(order); if (result > 0) return RedirectToAction("Index"); else return View(); }
private AddOrderViewModel GetAddOrderViewModel() { AddOrderViewModel addOrder = new AddOrderViewModel() { //CustomerID = "ALFKI", //ContactName = context.GetCustomerByCustomerID("ALFKI").ToString(), CustomerList = context.GetCustomerList(), OrderDate = DateTime.Now, ProductList = productContext.GetProducts(), EmployeeList = employeeContext.GetEmployees(), ShipperList = shipperContext.GetShippers(), Quantity = 1 }; return addOrder; }