public ActionResult CreateOrder(OrderModel model)
        {
            var orderRepository = new OrderRepository();
            var order = new Order
            {
                OrderId = model.OrderId,
                OrderDateTime = model.OrderDateTime,
                CustomerId = model.CustomerId

            };
            orderRepository.CreateOrder(order);
            return RedirectToAction("AddItem", new {id = model.OrderId});
        }
 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 ViewOrder(Guid id)
        {
            var repository = new OrderRepository();
            var order = repository.GetOrder(id);
            var model = new OrderModel
            {
                OrderId = order.OrderId,
                OrderCode = order.OrderCode,
                OrderDateTime = order.OrderDateTime,
                CustomerName = String.Format("{0} {1}", order.Customer.FirstName, order.Customer.LastName),
                OrderTotal = order.OrderTotal
            };
            model.OrderItems = order.OrderItems.Select(oi => new OrderItemModel
            {
                OrderItemId = oi.OrderItemId,
                OrderId = oi.OrderId,
                ProductName = oi.Product.ProductName,
                Quantity = oi.Quantity,
                OrderItemTotal = oi.OrderItemTotal.ToString("c")
            }).ToList();

            return View(model);
        }
 public ActionResult ViewOrders()
 {
     var repository = new OrderRepository();
     var orderModelList = repository.GetOrders().Select(o => new OrderModel
     {
         OrderId = o.OrderId,
         CustomerName = String.Format("{0} {1}", o.Customer.FirstName, o.Customer.LastName),
         OrderCode = o.OrderCode,
         OrderDateTime = o.OrderDateTime,
         OrderTotal = o.OrderTotal
     });
     return View(orderModelList);
 }