/// <summary>
 /// Deprecated Method for adding a new object to the PROCESSING EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPROCESSING(PROCESSING pROCESSING)
 {
     base.AddObject("PROCESSING", pROCESSING);
 }
        public bool SendToChicken(Guid order_id)
        {
            try
            {
                // Lấy dữ liệu order
                ORDER order = (from p in Context.ORDER
                                  where p.Id == order_id
                                  select p).SingleOrDefault();
                if (order == null) return false;

                //Lấy dữ liệu order detail
                List<ORDER_DETAIL> orderdtl;
                orderdtl = (from p in Context.ORDER_DETAIL
                            where p.ORDER_ID == order_id && p.STATUS=="Chờ làm"
                            select p).ToList();
                if (orderdtl.Count == 0) return false;

                //Đếm số lượng món đang làm
                int c;
                c = (from p in Context.PROCESSING
                     where p.STATUS == "Đang làm"
                     select p.Id).Count();
                decimal m;
                m = (from p in Context.PROCESSING
                     select (decimal?)p.PRIORITY).Max() ?? 0;
                for (int i = 0; i < orderdtl.Count; i++)
                {
                    PROCESSING proccess = new PROCESSING();
                    proccess.Id = Guid.NewGuid();
                    proccess.AMOUNT = orderdtl[i].AMOUNT;
                    proccess.CHEF_ID = orderdtl[i].CHEF_ID;
                    proccess.DISH_ID = orderdtl[i].DISH_ID;
                    proccess.TALBLE_ID = order.TABLE_ID;
                    proccess.ORDERDTL_ID = orderdtl[i].Id;
                    proccess.COMMENT = orderdtl[i].COMMENT;
                    if (i + c < 10)
                    {
                        proccess.PRIORITY = i + c + 1;
                        proccess.STATUS = "Đang làm";
                    }
                    else
                    {
                        proccess.PRIORITY = i+(int)m+1;
                        proccess.STATUS = "Chờ làm";
                    }
                    Context.PROCESSING.AddObject(proccess);
                    orderdtl[i].STATUS = "Đang làm";
                }
                
                //Thay đổi trạng thái của order
                order.STATUS = "Đang làm";

                //Commit change
                Context.SaveChanges();
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 /// <summary>
 /// Create a new PROCESSING 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="pRIORITY">Initial value of the PRIORITY property.</param>
 /// <param name="aMOUNT">Initial value of the AMOUNT property.</param>
 /// <param name="sTATUS">Initial value of the STATUS property.</param>
 /// <param name="tALBLE_ID">Initial value of the TALBLE_ID property.</param>
 /// <param name="oRDERDTL_ID">Initial value of the ORDERDTL_ID property.</param>
 public static PROCESSING CreatePROCESSING(global::System.Guid id, global::System.Guid dISH_ID, global::System.Int32 pRIORITY, global::System.Int32 aMOUNT, global::System.String sTATUS, global::System.Guid tALBLE_ID, global::System.Guid oRDERDTL_ID)
 {
     PROCESSING pROCESSING = new PROCESSING();
     pROCESSING.Id = id;
     pROCESSING.DISH_ID = dISH_ID;
     pROCESSING.PRIORITY = pRIORITY;
     pROCESSING.AMOUNT = aMOUNT;
     pROCESSING.STATUS = sTATUS;
     pROCESSING.TALBLE_ID = tALBLE_ID;
     pROCESSING.ORDERDTL_ID = oRDERDTL_ID;
     return pROCESSING;
 }