Exemple #1
0
 public void SaveCategory(Category category)
 {
     using (var context = new ClothMarketContext())
     {
         context.Categories.Add(category);
         context.SaveChanges();
     }
 }
Exemple #2
0
 public void UpdateCategory(Category category)
 {
     using (var context = new ClothMarketContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemple #3
0
 public int SaveOrder(Order order)
 {
     using (var context = new ClothMarketContext())
     {
         context.Orders.Add(order);
         return(context.SaveChanges());
     }
 }
 public void UpdateProduct(Product product)
 {
     using (var context = new ClothMarketContext())
     {
         context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
        public void DeleteProduct(int ID)
        {
            using (var context = new ClothMarketContext())
            {
                var product = context.Products.Find(ID);

                context.Products.Remove(product);
                context.SaveChanges();
            }
        }
        public void SaveProduct(Product product)
        {
            using (var context = new ClothMarketContext())
            {
                context.Entry(product.Category).State = System.Data.Entity.EntityState.Unchanged;

                context.Products.Add(product);
                context.SaveChanges();
            }
        }
Exemple #7
0
        public void DeleteCategory(int ID)
        {
            using (var context = new ClothMarketContext())
            {
                var category = context.Categories.Where(x => x.ID == ID).Include(x => x.Products).FirstOrDefault();

                context.Products.RemoveRange(category.Products); //first delete products of this category
                context.Categories.Remove(category);
                context.SaveChanges();
            }
        }
Exemple #8
0
        public bool UpdateOrderStatus(int ID, string status)
        {
            using (var context = new ClothMarketContext())
            {
                var order = context.Orders.Find(ID);

                order.Status = status;

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

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