Exemple #1
0
        public IHttpActionResult DeleteProductDate(int ID)
        {
            string Token = HttpContext.Current.Request.Form["Token"];
            //Find Date
            Product_NotAvaiableDates date = db.Product_NotAvaiableDates.SingleOrDefault(x => x.Product.Provider.Token == Token && x.ID == ID);

            if (date == null)
            {
                return(Ok(new { key = false, Message = "هذا التاريخ غير موجودة" }));
            }
            //Delete Date From DB
            db.Product_NotAvaiableDates.Remove(date);
            db.SaveChanges();
            return(Ok(new { key = true, Message = "تم مسح التاريخ بنجاح" }));
        }
Exemple #2
0
        public IHttpActionResult AddProductDate(int Product_ID)
        {
            string   Token = HttpContext.Current.Request.Form["Token"];
            DateTime Date  = Convert.ToDateTime(HttpContext.Current.Request.Form["Date"]);

            //Find Product
            Product product = db.Products.SingleOrDefault(x => x.ID == Product_ID && x.Provider.Token == Token);

            if (product == null)
            {
                return(Ok(new { key = false, Message = "هذا المنتج غير موجود" }));
            }
            //Add Date To DB
            Product_NotAvaiableDates notaviabledate = new Product_NotAvaiableDates {
                Date = Date, Product_ID = product.ID
            };

            db.Product_NotAvaiableDates.Add(notaviabledate);
            db.SaveChanges();
            return(Ok(new { key = true, Message = "تم اضافة التاريخ بنجاح" }));
        }