public IEnumerable <Company> Read() { using (context = new MvcInvoiceContext()) { var companies = context.Companies.ToList(); return(companies); } }
public Company Find(int Id) { using (context = new MvcInvoiceContext()) { var company = context.Companies.Where(res => res.Id == Id).FirstOrDefault(); return(company); } }
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(); } }