Beispiel #1
0
        public IHttpActionResult PutProduct(int id, Product product)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != product.ID)
            {
                return(BadRequest());
            }

            db.Entry(product).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
 public void UpdateCategory(Category category)
 {
     using (var context = new EAContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #3
0
 public void UpdateProduct(Product product)
 {
     using (var context = new EAContext())
     {
         context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #4
0
 public void UpdateFoodandMedicine(FoodandMedicine foodandMedicine)
 {
     using (var context = new EAContext())
     {
         context.Entry(foodandMedicine).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #5
0
 public void CreateReview(Review review)
 {
     using (var context = new EAContext())
     {
         context.Entry(review.Product).State = EntityState.Unchanged;
         context.Reviews.Add(review);
         context.SaveChanges();
     }
 }
Beispiel #6
0
        public void CreateProduct(Product product)
        {
            using (var context = new EAContext())
            {
                context.Entry(product.Category).State = EntityState.Unchanged;

                context.Products.Add(product);
                context.SaveChanges();
            }
        }
Beispiel #7
0
        public void CreateFoodandMedicine(FoodandMedicine foodandMedicine)
        {
            using (var context = new EAContext())
            {
                context.Entry(foodandMedicine.Category).State = EntityState.Unchanged;

                context.FoodandMedicines.Add(foodandMedicine);
                context.SaveChanges();
            }
        }
Beispiel #8
0
        public bool UpdateOrderStatus(int ID, string status)
        {
            using (var context = new EAContext())
            {
                var order = context.Orders.Find(ID);

                order.Status = status;

                context.Entry(order).State = EntityState.Modified;

                return(context.SaveChanges() > 0);
            }
        }