public static bool Insert(int MenuItemID, decimal Price, int Quantity)
 {
     try
     {
         using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
         {
             PL.TblOrderItem newRow = new TblOrderItem()
             {
                 OrderItemID = rc.TblOrderItems.Any() ? rc.TblOrderItems.Max(u => u.OrderItemID) + 1 : 1,
                 MenuItemId  = MenuItemID,
                 Price       = Price,
                 Quantity    = Quantity
             };
             rc.TblOrderItems.Add(newRow);
             rc.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public static bool Update(OrderItemModel orderItem)
        {
            try
            {
                if (orderItem.OrderItemID != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        TblOrderItem tblOrderItem = rc.TblOrderItems.FirstOrDefault(u => u.OrderItemID == orderItem.OrderItemID);

                        if (tblOrderItem != null)
                        {
                            tblOrderItem.OrderItemID = orderItem.OrderItemID;
                            tblOrderItem.Price       = orderItem.Price;
                            tblOrderItem.MenuItemId  = orderItem.MenuItemID;
                            tblOrderItem.Quantity    = orderItem.Quantity;


                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("Item was not found");
                        }
                    }
                }
                else
                {
                    throw new Exception("Must have a valid id");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public static bool Insert(OrderItemModel orderItem)
 {
     try
     {
         using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
         {
             PL.TblOrderItem newRow = new TblOrderItem()
             {
                 OrderItemID = rc.TblOrderItems.Any() ? rc.TblOrderItems.Max(u => u.OrderItemID) + 1 : 1,
                 OrderID     = orderItem.OrderID,
                 MenuItemId  = orderItem.MenuItemID,
                 Price       = orderItem.Price,
                 Quantity    = orderItem.Quantity
             };
             rc.TblOrderItems.Add(newRow);
             rc.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }