Exemple #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));
        }
Exemple #2
0
 public void UpdateCategory(Category category)
 {
     using (var context = new EAContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemple #3
0
 public void CreateCategory(Category category)
 {
     using (var context = new EAContext())
     {
         context.Categories.Add(category);
         context.SaveChanges();
     }
 }
Exemple #4
0
 public void UpdateProduct(Product product)
 {
     using (var context = new EAContext())
     {
         context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemple #5
0
 public int SaveOrder(Order order)
 {
     using (var context = new EAContext())
     {
         context.Orders.Add(order);
         return(context.SaveChanges());
     }
 }
Exemple #6
0
 public void UpdateFoodandMedicine(FoodandMedicine foodandMedicine)
 {
     using (var context = new EAContext())
     {
         context.Entry(foodandMedicine).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemple #7
0
 public void CreateReview(Review review)
 {
     using (var context = new EAContext())
     {
         context.Entry(review.Product).State = EntityState.Unchanged;
         context.Reviews.Add(review);
         context.SaveChanges();
     }
 }
Exemple #8
0
        public void CreateProduct(Product product)
        {
            using (var context = new EAContext())
            {
                context.Entry(product.Category).State = EntityState.Unchanged;

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

                context.FoodandMedicines.Add(foodandMedicine);
                context.SaveChanges();
            }
        }
Exemple #10
0
        public void DeleteCategory(int id)
        {
            using (var context = new EAContext())
            {
                //context.Entry(category).State = System.Data.Entity.EntityState.Deleted;

                var category = context.Categories.Find(id);
                context.Categories.Remove(category);
                context.SaveChanges();
            }
        }
Exemple #11
0
        public void DeleteProduct(int id)
        {
            using (var context = new EAContext())
            {
                //context.Entry(Product).State = System.Data.Entity.EntityState.Deleted;

                var product = context.Products.Find(id);
                context.Products.Remove(product);
                context.SaveChanges();
            }
        }
Exemple #12
0
        public void DeleteFoodandMedicine(int id)
        {
            using (var context = new EAContext())
            {
                //context.Entry(Product).State = System.Data.Entity.EntityState.Deleted;

                var foodandMedicine = context.FoodandMedicines.Find(id);
                context.FoodandMedicines.Remove(foodandMedicine);
                context.SaveChanges();
            }
        }
Exemple #13
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);
            }
        }