public int DeleteVendors(Vendor vendor) { using (var dbContext = new CompareTheGameEntities()) { var foundVendor = dbContext.Vendors.First(v => v.VendorID == vendor.VendorID); dbContext.Vendors.Remove(foundVendor); return(dbContext.SaveChanges()); } }
public int SaveVendor(Vendor vendor) { using (var dbContext = new CompareTheGameEntities()) { var user = HttpContext.Current.User.Identity.Name; if (vendor.VendorID == 0) { vendor.CreatedBy = user; vendor.CreatedDate = DateTime.Now; } vendor.ModifiedBy = user; vendor.ModifiedDate = DateTime.Now; dbContext.Vendors.AddOrUpdate(vendor); return(dbContext.SaveChanges()); } }