Beispiel #1
0
 public Product UpdateProduct(Product product)
 {
     using (var data = new MarketDbContext())
     {
         data.Entry(product).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         data.SaveChanges();
     }
     return(product);
 }
 public Category AddCategory(Category categories)
 {
     using (var data = new MarketDbContext())
     {
         data.Categories.Add(categories);
         data.SaveChanges();
     }
     return(categories);
 }
 public Category UpdateCategory(Category categories)
 {
     using (var data = new MarketDbContext())
     {
         data.Entry(categories).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         data.SaveChanges();
         return(categories);
     }
 }
        public Category DeleteCategory(int id)
        {
            Category categories = new Category();

            using (var data = new MarketDbContext())
            {
                categories = data.Categories.FirstOrDefault(x => x.Id == id);
                data.Categories.Remove(categories);
                data.SaveChanges();
            }
            return(categories);
        }
 public T Create(T entity)
 {
     Db.Set <T>().Add(entity);
     Db.SaveChanges();
     return(entity);
 }