public void Create(Company entity) { using (context = new MvcInvoiceContext()) { context.Companies.Add(entity); context.SaveChanges(); } }
public void Delete(Company entity) { using (context = new MvcInvoiceContext()) { context.Companies.Attach(entity); context.Companies.Remove(entity); context.SaveChanges(); } }
public void Update(Company entity) { using (context = new MvcInvoiceContext()) { var currentCompany = context.Companies.Where(res => res.Id == entity.Id).FirstOrDefault(); currentCompany.PhoneNumber = entity.PhoneNumber; currentCompany.Email = entity.Email; currentCompany.BusinessName = entity.BusinessName; currentCompany.ZipCode = entity.ZipCode; currentCompany.Address = entity.Address; context.SaveChanges(); } }