Inheritance: System.Data.Objects.DataClasses.EntityObject
コード例 #1
0
ファイル: OrdersController.cs プロジェクト: feedme/FeedMe
        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");
        }
コード例 #2
0
ファイル: OrderItemsRepository.cs プロジェクト: feedme/FeedMe
 public void delete(OrderItem orderitem)
 {
     entities.OrderItems.DeleteObject(orderitem);
 }
コード例 #3
0
ファイル: OrderItemsRepository.cs プロジェクト: feedme/FeedMe
 public void add(OrderItem orderitem)
 {
     entities.OrderItems.AddObject(orderitem);
 }
コード例 #4
0
ファイル: FeedMeDB.Designer.cs プロジェクト: feedme/FeedMe
 /// <summary>
 /// Deprecated Method for adding a new object to the OrderItems EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOrderItems(OrderItem orderItem)
 {
     base.AddObject("OrderItems", orderItem);
 }
コード例 #5
0
ファイル: FeedMeDB.Designer.cs プロジェクト: feedme/FeedMe
 /// <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;
 }