public void Update(Order order)
 {
     context.Entry(order).State = System.Data.Entity.EntityState.Modified;
     context.SaveChanges();
 }
 public void Create(Order order)
 {
     context.Orders.Add(order);
     context.SaveChanges();
 }
        public ActionResult CheckOut(BasketViewModel model)
        {
            Basket basket = _basketRepository.Get(User.Identity.Name);

            if (basket != null)
            {
                Order order = new Order
                {
                    Items = new List<OrderLine>(),
                    Status = OrderStatus.Draft,
                    UserId = basket.UserId,
                    OrderDate = DateTime.Today
                };

                foreach (BasketItem basketItem in basket.Items)
                {
                    OrderLine orderLine = new OrderLine { itemId = basketItem.ItemId, Quantity = basketItem.Quantity };
                    Item item = _itemRepository.Get(basketItem.ItemId);
                    orderLine.unitPrice = item.Price;
                    orderLine.Name = item.Name;
                    order.Items.Add(orderLine);
                }
                _orderRepository.Create(order);

                basket.Items.Clear();
                _basketRepository.Delete(basket.Id);

                return Redirect(Url.Action("Confirm", "Order", new {orderId = order.Id}));


            }
            return View(model);
        }