public void Add(TEntity entity) { entity.IsDeleted = false; entity.AddDate = DateTime.Now; entity.UpdateDate = DateTime.Now; dbSet.Add(entity); db.SaveChanges(); }
//update metodu public static void UpdateProduct(Product product) { using (BilgeAdamContext db = new BilgeAdamContext()) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); } }
public static void UpdateSupplier(Supplier supplier) { using (BilgeAdamContext db = new BilgeAdamContext()) { db.Entry(supplier).State = EntityState.Modified; db.SaveChanges(); } }
//id ye göre HARD silme metodu public static void HardDeleteProduct(int id) { using (BilgeAdamContext db = new BilgeAdamContext()) { Product product = db.Products.FirstOrDefault(q => q.ID == id); db.Products.Remove(product); db.SaveChanges(); } }
//idye göre silme public static void DeleteProduct(int id) { using (BilgeAdamContext db = new BilgeAdamContext()) { Product product = db.Products.FirstOrDefault(q => q.ID == id); product.IsDeleted = true; product.DeleteDate = DateTime.Now; db.SaveChanges(); } }
public static void DeleteCategory(int id) { using (BilgeAdamContext db = new BilgeAdamContext()) { Category category = db.Categories.FirstOrDefault(q => q.ID == id); category.IsDeleted = true; category.DeleteDate = DateTime.Now; db.SaveChanges(); } }
public static void DeleteSupplier(int id) { using (BilgeAdamContext db = new BilgeAdamContext()) { Supplier supplier = db.Suppliers.FirstOrDefault(q => q.ID == id); if (supplier != null) { supplier.IsDeleted = true; db.SaveChanges(); } } }
public static void AddSupplier(Supplier supplier) { using (BilgeAdamContext db = new BilgeAdamContext()) { supplier.AddDate = DateTime.Now; supplier.UpdateDate = DateTime.Now; supplier.IsDeleted = false; db.Suppliers.Add(supplier); db.SaveChanges(); } }
//public static List<Product> GetAllProducts() //{ // using (BilgeAdamContext db = new BilgeAdamContext()) // { // return db.Products.Where(q => q.IsDeleted == false).ToList(); // } //} public static void AddProduct(Product product) { using (BilgeAdamContext db = new BilgeAdamContext()) { product.AddDate = DateTime.Now; product.IsDeleted = false; product.UpdateDate = DateTime.Now; db.Products.Add(product); db.SaveChanges(); } }
public static void AddCategory(Category category) { using (BilgeAdamContext db = new BilgeAdamContext()) { category.AddDate = DateTime.Now; category.IsDeleted = false; category.UpdateDate = DateTime.Now; db.Categories.Add(category); db.SaveChanges(); } }
public static void AddAdminUser(AdminUser adminuser) { using (BilgeAdamContext db = new BilgeAdamContext()) { adminuser.InsertedUserID = 1; adminuser.UpdatedUserID = 1; adminuser.AddDate = DateTime.Now; adminuser.IsDeleted = false; adminuser.UpdateDate = DateTime.Now; db.AdminUsers.Add(adminuser); db.SaveChanges(); } }