public ActionResult AddItem(OrderItemModel model) { var orderItem = new OrderItem { OrderId = model.OrderId, OrderItemId = Guid.NewGuid(), OrderItemTotal = Convert.ToDecimal(model.OrderItemTotal.Replace("$", "")), ProductId = model.ProductId, Quantity = model.Quantity }; var repository = new OrderRepository(); repository.AddOrderItem(orderItem); return RedirectToAction("ViewOrder", new {id = model.OrderId}); }
public ActionResult AddItem(Guid id) { var repository = new ProductRepository(); var productDictionary = repository.GetProducts().OrderBy(product => product.ProductName) .Select(p => new {ProductId = p.ProductId, ProductName = p.ProductName}) .ToDictionary(x => x.ProductId, x => x.ProductName); var quantityDictionary = new Dictionary<int, int>(); for (int i = 1; i <= 10; i++) { quantityDictionary.Add(i, i); } var model = new OrderItemModel { OrderItemId = Guid.NewGuid(), OrderId = id, OrderItemTotal = 0.ToString("c"), ProductDictionary = productDictionary, QuantityDictionary = quantityDictionary }; return View(model); }