public void Update(T entity) { using var context = new ShopContext(); var updatedEntity = context.Entry(entity); updatedEntity.State = EntityState.Modified; context.SaveChanges(); }
public void Delete(T entity) { using (var context = new ShopContext()) { var deletedEntity = context.Entry(entity); deletedEntity.State = EntityState.Deleted; context.SaveChanges(); } }
public void Create(T entity) { using (var context = new ShopContext()) { var addedEntity = context.Entry(entity); addedEntity.State = EntityState.Added; context.SaveChanges(); } }