public ActionResult AddItemToOrder(System.Guid itemId,System.Guid menuId,FormCollection collection) { MembershipUser user = Membership.GetUser(); var orders = ordersRepository.GetOrdersByStatusAndUserId("new",(Guid)user.ProviderUserKey); var vendor = itemsRepository.GetVendorByItemId(itemId); OrderItem orderitem = new OrderItem(); if (orders.Count() < 1) { Order order = new Order(); order.OrderId = System.Guid.NewGuid(); order.VendorId = vendor.VendorId; order.UserId = (Guid)user.ProviderUserKey; order.Status = "new"; ordersRepository.add(order); ordersRepository.save(); orderitem.OrderItemId = System.Guid.NewGuid(); orderitem.ItemId = itemId; orderitem.OrderId = order.OrderId; orderitem.Quantity = Convert.ToInt32(collection[0]); } else { orderitem.OrderItemId = System.Guid.NewGuid(); orderitem.ItemId = itemId; orderitem.OrderId = orders.First().OrderId; orderitem.Quantity = Convert.ToInt32(collection[0]); } if (TryUpdateModel(orderitem)) { orderitemsRepository.add(orderitem); orderitemsRepository.save(); return RedirectToAction("Show","Menus",new { id=menuId }); } return RedirectToAction("Index"); }
public void delete(OrderItem orderitem) { entities.OrderItems.DeleteObject(orderitem); }
public void add(OrderItem orderitem) { entities.OrderItems.AddObject(orderitem); }
/// <summary> /// Deprecated Method for adding a new object to the OrderItems EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToOrderItems(OrderItem orderItem) { base.AddObject("OrderItems", orderItem); }
/// <summary> /// Create a new OrderItem object. /// </summary> /// <param name="orderId">Initial value of the OrderId property.</param> /// <param name="itemId">Initial value of the ItemId property.</param> /// <param name="quantity">Initial value of the Quantity property.</param> /// <param name="orderItemId">Initial value of the OrderItemId property.</param> public static OrderItem CreateOrderItem(global::System.Guid orderId, global::System.Guid itemId, global::System.Int32 quantity, global::System.Guid orderItemId) { OrderItem orderItem = new OrderItem(); orderItem.OrderId = orderId; orderItem.ItemId = itemId; orderItem.Quantity = quantity; orderItem.OrderItemId = orderItemId; return orderItem; }