public void Update(DomainModels.DTO.EF.ProductCategory ref_ProductCategory) { using (var context = new DomainModels.DTO.EF.OnlineShopEntities()) { try { var itemToUpdate = context.ProductCategory.SingleOrDefault(x => x.Id == ref_ProductCategory.Id); if (itemToUpdate != null) { context.Entry(itemToUpdate).CurrentValues.SetValues(ref_ProductCategory); context.SaveChanges(); } } catch (Exception) { throw; } finally { if (context != null) { context.Dispose(); } } } }
public void Insert(DomainModels.DTO.EF.ProductCategory ref_ProductCategory) { using (var context = new DomainModels.DTO.EF.OnlineShopEntities()) { try { context.ProductCategory.Add(ref_ProductCategory); context.SaveChanges(); } catch (Exception) { throw; } finally { if (context != null) { context.Dispose(); } } } }