Exemplo n.º 1
0
        public OrderDish GetOrderDish(int id) //when we know the return is only one result we use an IF-loop as decision maker
        {
            OrderDish dish             = null;
            string    connectionString = Configuration.GetConnectionString("DefaultConnection");

            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string     query = "SELECT * FROM OrderDishes where OrderDishID = @id";
                    SqlCommand cmd   = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@id", id);

                    cn.Open();

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        if (dr.Read())
                        {
                            dish = new OrderDish();

                            dish.OrderDishID = (int)dr["OrderDishID"];
                            dish.DishID      = (int)dr["DishID"];
                            dish.Quantity    = (int)dr["Quantity"];
                            dish.Price       = (long)dr["Price"];
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(dish);
        }
Exemplo n.º 2
0
        public int UpdateOrderDish(OrderDish orderDish)
        {
            int result = 0;


            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string     query = "UPDATE OrderDish SET IdDish=@idDish,Quantity=@quantity,OrderDishPrice=@orderDishPrice WHERE IdOrder=@id";
                    SqlCommand cmd   = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@id", orderDish.IdOrder);
                    cmd.Parameters.AddWithValue("@idDish", orderDish.IdDish);
                    cmd.Parameters.AddWithValue("@quantity", orderDish.Quantity);
                    cmd.Parameters.AddWithValue("@orderDishPrice", orderDish.OrderDishPrice);

                    cn.Open();

                    result = cmd.ExecuteNonQuery();
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(result);
        }
Exemplo n.º 3
0
        public OrderDish AddOrderDish(OrderDish dish)
        {
            string connectionString = Configuration.GetConnectionString("DefaultConnection");

            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string query = "Insert into OrderDishes(OrderDishID,DishID , Quantity, Price)" +
                                   "values (@id, @dishId, @quantity, @price); SELECT SCOPE_IDENTITY()";
                    SqlCommand cmd = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@id", dish.OrderDishID);
                    cmd.Parameters.AddWithValue("@restId", dish.DishID);
                    cmd.Parameters.AddWithValue("@quantity", dish.Quantity);
                    cmd.Parameters.AddWithValue("@price", dish.Price);

                    cn.Open();

                    dish.DishID = Convert.ToInt32(cmd.ExecuteScalar());
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(dish);
        }
Exemplo n.º 4
0
        public OrderDish GetOrderDish(int id)
        {
            OrderDish orderdishes = null;


            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string     query = "Select * from Order_dishes where IdOrderDishes = @id";
                    SqlCommand cmd   = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@id", id);

                    cn.Open();

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        if (dr.Read())
                        {
                            orderdishes = new OrderDish();

                            orderdishes.IdOrder  = (int)dr["IdOrder"];
                            orderdishes.IdDishes = (int)dr["IdDishes"];
                            orderdishes.Quantity = (int)dr["Quantity"];
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(orderdishes);
        }
Exemplo n.º 5
0
        public int UpdateOrderDish(OrderDish dish)
        {
            int    result           = 0;
            string connectionString = Configuration.GetConnectionString("DefaultConnection");

            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string     query = "Update Dishes SET Quantity = @quantity where OrderDishID = @id";
                    SqlCommand cmd   = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@id", dish.DishID);
                    cmd.Parameters.AddWithValue("@quantity", dish.Quantity);

                    cn.Open();

                    result = cmd.ExecuteNonQuery();
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(result);
        }
Exemplo n.º 6
0
        public OrderDish AddOrderDish(OrderDish orderDish)
        {
            //string connectionString = Configuration.GetConnectionString("DefaultConnection");

            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string query = "insert into order_dishes(fk_orders, fk_dishes, quantity) " +
                                   "values(@fk_orders, @fk_dishes, @quantity);" +
                                   "select scope_identity();";
                    SqlCommand cmd = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@fk_orders", orderDish.order.id);
                    cmd.Parameters.AddWithValue("@fk_dishes", orderDish.dish.id);
                    cmd.Parameters.AddWithValue("@quantity", orderDish.quantity);

                    cn.Open();

                    orderDish.id = Convert.ToInt32(cmd.ExecuteScalar());
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(orderDish);
        }
        private void Delete_Order1(object sender, RoutedEventArgs e)
        {
            var       OrderRepo = new OrderRepository();
            OrderDish orderDish = Stolik1.SelectedItem as OrderDish;

            OrderRepo.DeleteOrder(orderDish.OrderID);
            this.NavigationService.Navigate(new OrdersPage());
        }
        public ActionResult DeleteConfirmed(int id)
        {
            OrderDish orderDish = db.OrderDishes.Find(id);

            db.OrderDishes.Remove(orderDish);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 9
0
        // ***
        public async Task <IResponseDto> CreateOrder(CreateOrderDto request)
        {
            bool                    areAllAvailable        = true;
            var                     wantedDishesEnumerator = request.WantedDishes.GetEnumerator();
            IList <Dish>            wantedDishes           = new List <Dish>();
            IDictionary <Guid, int> wantedDishesCount      = new Dictionary <Guid, int>();

            while (wantedDishesEnumerator.MoveNext() && areAllAvailable == true)
            {
                var wantedDish = await _unitOfWork.DishesRepository.Get(wantedDishesEnumerator.Current.Id);

                wantedDishes.Add(wantedDish);
                wantedDishesCount.Add(wantedDish.Id, wantedDishesEnumerator.Current.Count);

                areAllAvailable = wantedDish.IsAvailable;
            }
            wantedDishesEnumerator.Dispose();

            if (areAllAvailable == false)
            {
                return(ErrorResponseDto.Create("Some dishes are not available."));
            }
            var createdOrder = Order.Create(DateTime.Now, request.Adress);
            await _unitOfWork.OrdersRepository.Add(createdOrder);

            foreach (var wantedDish in wantedDishes)
            {
                wantedDishesCount.TryGetValue(wantedDish.Id, out int count);
                var orderDish = OrderDish.Create(wantedDish, createdOrder, count);

                await _unitOfWork.OrderDishesRepository.Add(orderDish);

                foreach (var wantedDishIngredient in wantedDish.DishIngredients)
                {
                    IngredientOnStock usedIngredient = wantedDishIngredient.Ingredient;
                    usedIngredient.Quantity -= wantedDishIngredient.Quantity;
                    await _unitOfWork.IngredientsRepository.Update(wantedDishIngredient.Ingredient);

                    foreach (var usedIngredientDish in wantedDishIngredient.Ingredient.IngredientDishes)
                    {
                        if (usedIngredientDish.Quantity > wantedDishIngredient.Ingredient.Quantity)
                        {
                            usedIngredientDish.Dish.IsAvailable = false;
                            await _unitOfWork.DishesRepository.Update(usedIngredientDish.Dish);
                        }
                    }
                }
            }

            await _unitOfWork.CommitAsync();

            // cauta dishurile orderului
            //verifica daca sunt available
            // create order
            // scade din fiecare ingredient folosit in dishurile alese
            //si pentru fiecare ingredient modificat se verifica dishurile la care se foloseste ingredientul (is available?)
            return(SuccessResponseDto.Create(_mapper.Map <OrderDto>(createdOrder)));
        }
Exemplo n.º 10
0
 public bool CreateOrderDish(OrderDish instance)
 {
     if (instance.OrderDishId == 0)
     {
         Db.OrderDishs.InsertOnSubmit(instance);
         Db.OrderDishs.Context.SubmitChanges();
         return(true);
     }
     return(false);
 }
 public ActionResult Edit([Bind(Include = "OrderDishID,Count")] OrderDish orderDish)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orderDish).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(orderDish));
 }
Exemplo n.º 12
0
        static OrderDish MakeFryedPotato()
        {
            OrderDish potatoFree = Oficiant.GetOrderDish;

            potatoFree += SmallCooker.CleanProduct;
            potatoFree += SmallCooker.PrepareProduct;
            potatoFree += ShefCooker.CookDish;
            potatoFree += Oficiant.ServiceDish;
            potatoFree += Oficiant.TakeMoney;
            return(potatoFree);
        }
        public ActionResult Create([Bind(Include = "OrderDishID,Count")] OrderDish orderDish)
        {
            if (ModelState.IsValid)
            {
                db.OrderDishes.Add(orderDish);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(orderDish));
        }
Exemplo n.º 14
0
        public bool RemoveOrderDish(int OrderDishId)
        {
            OrderDish instance = Db.OrderDishs.FirstOrDefault(p => p.OrderDishId == OrderDishId);

            if (instance != null)
            {
                Db.OrderDishs.DeleteOnSubmit(instance);
                Db.OrderDishs.Context.SubmitChanges();
                return(true);
            }

            return(false);
        }
Exemplo n.º 15
0
        public bool UpdateOrderDish(OrderDish instance)
        {
            OrderDish cache = Db.OrderDishs.FirstOrDefault(p => p.OrderDishId == instance.OrderDishId);

            if (instance.OrderDishId != 0)
            {
                cache.DishId  = instance.DishId;
                cache.OrderId = instance.OrderId;
                cache.Count   = instance.Count;
                Db.OrderDishs.Context.SubmitChanges();
                return(true);
            }
            return(false);
        }
        // GET: OrderDishes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OrderDish orderDish = db.OrderDishes.Find(id);

            if (orderDish == null)
            {
                return(HttpNotFound());
            }
            return(View(orderDish));
        }
Exemplo n.º 17
0
 static void Order(Client client, OrderDish orderDish)
 {
     if (client.Job == "Taxes")
     {
         orderDish -= Oficiant.TakeMoney;
         orderDish += (Dish d) =>
         {
             d.Price = 0;
         };
     }
     if (client.Job == "Police")
     {
         orderDish -= Oficiant.TakeMoney;
         orderDish += Oficiant.GiveMoney;
     }
 }
Exemplo n.º 18
0
        public List <OrderDish> GetOrderDishByOrderId(int id)
        {
            List <OrderDish> results = null;

            //string connectionString = Configuration.GetConnectionString("DefaultConnection");

            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string     query = "Select * from order_dishes where fk_orders = @id";
                    SqlCommand cmd   = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@id", id);

                    cn.Open();

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            if (results == null)
                            {
                                results = new List <OrderDish>();
                            }

                            OrderDish orderDish = new OrderDish();

                            orderDish.id       = (int)dr["id"];
                            orderDish.quantity = (int)dr["quantity"];
                            // Voir si modifications souhaitées
                            OrdersDB ordersDB = new OrdersDB(Configuration);
                            orderDish.order = ordersDB.GetOrderById((int)dr["fk_orders"]);
                            DishesDB dishesDB = new DishesDB(Configuration);
                            orderDish.dish = dishesDB.GetDishById((int)dr["fk_dishes"]);

                            results.Add(orderDish);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(results);
        }
        public IActionResult AddToCart()
        {
            //System.Diagnostics.Debug.WriteLine(Request.Form["qty"]);
            int  quantity = int.Parse(Request.Form["qty"]);
            int  dishid   = int.Parse(Request.Form["dishId"]);
            Dish dish     = dishesManager.GetDishById(dishid);
            int  userid   = (int)HttpContext.Session.GetInt32("userid");


            //int[] order = { userid, dish.id, quantity };

            // le user veut rajouter qqch au panier, déjà qqch dedans ?
            // => orderid dans la session
            int orderid = (int)HttpContext.Session.GetInt32("orderid").GetValueOrDefault();

            System.Diagnostics.Debug.WriteLine("-----------------orderid=" + orderid);
            Order order = new Order();

            if (orderid != 0) // dans ce cas on rajoute une ligne dans order_dishes
            {
                order = ordersManager.GetOrderById(orderid);
            }
            else // sinon on doit créer une commande
            {
                Customer customer = customersManager.GetCustomerById(userid);
                //Deliverer deliverer = deliverersManager.GetDelivererForCity(customer.city.id);
                // On assigne un livreur temporaire à la commande
                Deliverer deliverer = deliverersManager.GetTempDeliverer();
                order = new Order {
                    customer = customer, deliverer = deliverer, delivery_time_requested = DateTime.Now
                };
                order = ordersManager.AddOrder(order);
                HttpContext.Session.SetInt32("orderid", order.id);
                // on stocke l'id de la ville pour qu'on ne puisse commander que dans une ville par commande
                HttpContext.Session.SetInt32("cityid", dish.restaurant.city.id);
            }

            HttpContext.Session.SetInt32("addedToCart", 1);
            OrderDish orderDish = new OrderDish {
                order = order, dish = dish, quantity = quantity
            };

            orderDishesManager.AddOrderDish(orderDish);


            return(RedirectToAction("List", "Dishes", new { id = Request.Form["restaurantId"] }));
        }
Exemplo n.º 20
0
        public ActionResult Create(int id, OrderDish od)
        {
            int idOrder = (int)HttpContext.Session.GetInt32("idOrder");

            var creation = new OrderDish();

            creation.IdOrder = idOrder;
            creation.IdDish  = id;


            if (od.Quantity > 0 && od.Quantity <= 20)
            {
                creation.Quantity = od.Quantity;
            }
            else
            {
                ViewData["Message"] = "La Quantité doit être entre 1 et 20 !";
                return(View());
            }


            var dish = DishesManager.GetDish(id);

            creation.OrderDishPrice = dish.DishPrice * creation.Quantity;

            var test = OrderDishManager.GetOrderDishes(idOrder);

            if (test != null)
            {
                foreach (var t in test)
                {
                    if (t.IdDish == id)
                    {
                        return(RedirectToAction("Update", creation));
                    }
                }
            }
            else
            {
                OrderDishManager.AddOrderDish(creation);
            }



            return(RedirectToAction("GetAllDishes", "Dish"));
        }
Exemplo n.º 21
0
        public ActionResult Update(OrderDish orderDish)
        {
            var orderdishDb = OrderDishManager.GetOrderDish(orderDish.IdOrder, orderDish.IdDish);

            if (orderdishDb.Quantity + orderDish.Quantity < 0 || orderdishDb.Quantity + orderDish.Quantity > 20)
            {
                ViewData["Message"] = "La Quantité doit être entre 1 et 20 !";
                return(RedirectToAction("Create", orderDish.IdDish));
            }

            orderdishDb.Quantity       += orderDish.Quantity;
            orderdishDb.OrderDishPrice += orderDish.OrderDishPrice;

            OrderDishManager.UpdateOrderDish(orderdishDb);

            return(RedirectToAction("GetAllDishes", "Dish"));
        }
Exemplo n.º 22
0
        public List <OrderDish> GetOrderDishes(int id)
        {
            List <OrderDish> results = null;


            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string     query = "SELECT * FROM OrderDish WHERE IdOrder = @id";
                    SqlCommand cmd   = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@id", id);


                    cn.Open();

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            if (results == null)
                            {
                                results = new List <OrderDish>();
                            }

                            OrderDish orderDishes = new OrderDish();

                            orderDishes.IdOrder        = (int)dr["IdOrder"];
                            orderDishes.IdDish         = (int)dr["IdDish"];
                            orderDishes.Quantity       = (int)dr["Quantity"];
                            orderDishes.OrderDishPrice = (decimal)dr["OrderDishPrice"];


                            results.Add(orderDishes);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(results);
        }
Exemplo n.º 23
0
        // POST api/orderdish/
        public HttpResponseMessage Post([FromBody] OrderDish value)
        {
            ServerValidationInfo vi = null;

            value.UpdateDate = DateTime.Now;
            if (!ModelState.IsValid)
            {
                vi = new ServerValidationInfo(ModelState);
            }
            if (vi != null && vi.ContainsError)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, vi));
            }
            context.Entry(value).State = System.Data.EntityState.Added;
            context.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.OK, value));
        }
        public IActionResult DeleteItem(int id)
        {
            OrderDish        od          = orderDishesManager.GetOrderDishById(id);
            int              orderid     = od.order.id;
            List <OrderDish> orderDishes = orderDishesManager.GetOrderDishByOrderId(orderid);


            orderDishesManager.DeleteOrderDish(id);

            // S'il y a qu'un seul item dans la commande, il faut supprimer le verrour sur la ville
            if (orderDishes.Count() == 1)
            {
                HttpContext.Session.Remove("orderid");
                HttpContext.Session.Remove("cityid");
                ordersStatusHistoryManager.DeleteOrderStatusHistoryByOrderId(orderid);
                ordersManager.DeleteOrderById(orderid);
            }
            HttpContext.Session.SetInt32("deletedItem", 1);
            return(RedirectToAction("DisplayCart", "Orders"));
        }
Exemplo n.º 25
0
 public void AddOrderDishes(OrderDish orderDish)
 {
     try
     {
         using (SqlConnection cn = new SqlConnection(connectionString))
         {
             String     query = "INSERT INTO Order_dishes(IdOrder,IdDishes,Quantity) values(@IdOrder,@IdDishes,@Quantity)";
             SqlCommand cmd   = new SqlCommand(query, cn);
             cmd.Parameters.AddWithValue("@IdDishes", orderDish.IdDishes);
             cmd.Parameters.AddWithValue("@IdOrder", orderDish.IdOrder);
             cmd.Parameters.AddWithValue("@Quantity", orderDish.Quantity);
             cn.Open();
             cmd.ExecuteScalar();
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 26
0
        public List <OrderDish> GetOrderDishes()
        {
            List <OrderDish> results = null;


            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string     query = "SELECT * FROM Order_dishes";
                    SqlCommand cmd   = new SqlCommand(query, cn);

                    cn.Open();

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            if (results == null)
                            {
                                results = new List <OrderDish>();
                            }

                            OrderDish orderDishes = new OrderDish();

                            orderDishes.IdOrder  = (int)dr["IdOrder"];
                            orderDishes.IdDishes = (int)dr["IdDishes"];
                            orderDishes.Quantity = (int)dr["Quantity"];

                            results.Add(orderDishes);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(results);
        }
Exemplo n.º 27
0
        public List <OrderDish> GetOrderDishes() //if we know the query returns multiple results use while loop
        {
            List <OrderDish> results          = null;
            string           connectionString = Configuration.GetConnectionString("DefaultConnection");

            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string     query = "SELECT * FROM OrderDishes";
                    SqlCommand cmd   = new SqlCommand(query, cn);

                    cn.Open();

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            if (results == null)
                            {
                                results = new List <OrderDish>();
                            }

                            OrderDish dish = new OrderDish();

                            dish.OrderDishID = (int)dr["OrderDishID"];
                            dish.DishID      = (int)dr["DishID"];
                            dish.Price       = (long)dr["Price"];

                            results.Add(dish);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(results);
        }
Exemplo n.º 28
0
 protected void dell_OrderDish(int Id)//удаление рецепта из заказа
 {
     if (UserAct.Status == "guest")
     {
         List <OrderDish> asd    = (List <OrderDish>)Session["OrderDishUser"];
         OrderDish        od     = asd.Where(p => p.DishId == Id).FirstOrDefault();
         Order            curord = (Order)Session["OrderUser"];
         curord.Price -= (decimal)Repository.Dishs.Where(p => (p.DishId == Id)).FirstOrDefault().Price *od.Count;
         asd.Remove(od);
         Session["OrderUser"]     = curord;
         Session["OrderDishUser"] = asd;
     }
     else
     {
         OrderDish delord = Repository.OrderDishs.Where(p => (p.OrderId == CheckOrders.OrderId && p.DishId == Id)).FirstOrDefault();
         Order     curord = Repository.Orders.Where(p => p.OrderId == CheckOrders.OrderId).FirstOrDefault();
         curord.Price -= (decimal)Repository.Dishs.Where(p => (p.DishId == Id)).FirstOrDefault().Price *delord.Count;
         Repository.UpdateOrder(curord);
         Repository.RemoveOrderDish(delord.OrderDishId);
     }
     Response.Redirect("~/Page/BasketPage.aspx");
 }
Exemplo n.º 29
0
        public OrderDish GetOrderDish(int idOrder, int idDish)
        {
            OrderDish orderDish = null;


            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string     query = "SELECT * FROM OrderDish WHERE IdOrder = @idOrder AND IdDish = @idDish";
                    SqlCommand cmd   = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@idOrder", idOrder);
                    cmd.Parameters.AddWithValue("@idDish", idDish);

                    cn.Open();

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        if (dr.Read())
                        {
                            orderDish = new OrderDish();

                            orderDish.IdOrder        = (int)dr["IdOrder"];
                            orderDish.IdDish         = (int)dr["IdDish"];
                            orderDish.Quantity       = (int)dr["Quantity"];
                            orderDish.OrderDishPrice = (decimal)dr["OrderDishPrice"];
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(orderDish);
        }
Exemplo n.º 30
0
        // PUT api/orderdish/
        public HttpResponseMessage Put([FromBody] OrderDish value, string filter = null)
        {
            ServerValidationInfo vi = null;

            value.UpdateDate = DateTime.Now;
            if (!ModelState.IsValid)
            {
                vi = new ServerValidationInfo(ModelState);
            }
            if (filter == null)
            {
                context.Entry(value).State = System.Data.EntityState.Modified;
            }
            else
            {
                var old = context.OrderDishs.SingleOrDefault(queryBuider.CreateWhere(filter));
                old.Id            = value.Id;
                old.OrderId       = value.OrderId;
                old.DishId        = value.DishId;
                old.DishPrice     = value.DishPrice;
                old.Quantity      = value.Quantity;
                old.SizeId        = value.SizeId;
                old.DressingId    = value.DressingId;
                old.DressingPrice = value.DressingPrice;
                old.SubTotal      = value.SubTotal;
                old.UpdateDate    = value.UpdateDate;
                old.Remarks       = value.Remarks;
                old.UpdateUserId  = value.UpdateUserId;
            }
            if (vi != null && vi.ContainsError)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, vi));
            }
            var result = context.SaveChanges() > 0;

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }