/// <summary>
 /// Create a new ORDER_DETAIL object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="dISH_ID">Initial value of the DISH_ID property.</param>
 /// <param name="aMOUNT">Initial value of the AMOUNT property.</param>
 /// <param name="oRDER_ID">Initial value of the ORDER_ID property.</param>
 public static ORDER_DETAIL CreateORDER_DETAIL(global::System.Guid id, global::System.Guid dISH_ID, global::System.Int32 aMOUNT, global::System.Guid oRDER_ID)
 {
     ORDER_DETAIL oRDER_DETAIL = new ORDER_DETAIL();
     oRDER_DETAIL.Id = id;
     oRDER_DETAIL.DISH_ID = dISH_ID;
     oRDER_DETAIL.AMOUNT = aMOUNT;
     oRDER_DETAIL.ORDER_ID = oRDER_ID;
     return oRDER_DETAIL;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the ORDER_DETAIL EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToORDER_DETAIL(ORDER_DETAIL oRDER_DETAIL)
 {
     base.AddObject("ORDER_DETAIL", oRDER_DETAIL);
 }
        //Inserted ordered dishes
        public Boolean InsertOrdered(List<OrderDetailDTO> lst, short table_code)
        {
            try
            {

                ORDER order;
                OrderDTO query = (from p in Context.ORDER
                                  where p.TABLES_INFO.CODE == table_code
                                  select new OrderDTO()
                                  {
                                     ID=p.Id,
                                     STATUS=p.STATUS 
                                  }).SingleOrDefault();
                if (query == null)
                {
                    order = new ORDER();
                    query = new OrderDTO();
                    order.Id = Guid.NewGuid();
                    query.ID = order.Id;
                    Guid table_id = (from p in Context.TABLES_INFO where p.CODE == table_code select p.Id).SingleOrDefault();
                    order.TABLE_ID = table_id;
                    order.ADD_TIME = DateTime.Now;
                    order.STATUS = "Chờ xác nhận";
                    query.STATUS = order.STATUS;
                    Context.ORDER.AddObject(order);
                }
                foreach (OrderDetailDTO item in lst)
                {
                    ORDER_DETAIL orderdtl = new ORDER_DETAIL();
                    orderdtl.Id  = Guid.NewGuid();
                    ChefDTO chef = GetChefFree();
                    if (chef != null) orderdtl.CHEF_ID = chef.ID;
                    orderdtl.AMOUNT = item.AMOUNT;
                    orderdtl.DISH_ID = item.DISH_ID;
                    orderdtl.ORDER_ID = query.ID;
                    orderdtl.STATUS = "Chờ làm";
                    Context.ORDER_DETAIL.AddObject(orderdtl);
                }
                Context.SaveChanges();
                if (query.STATUS == "Đang làm")
                {
                    ProccessRepostitory rep = new ProccessRepostitory();
                    rep.SendToChicken(query.ID);
                }
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }