public int NewInvoice(int BusinessNumber, int CustomerNumber) { using (CustomerManagementSystemContext context = new CustomerManagementSystemContext()) { var business = new BusinessAccount(BusinessNumber); var customer = new Customer(CustomerNumber); var newInvoice = new Invoice { CreationDate = DateTime.Now, BusinessNumber = business.BusinessNumber, BusinessName = business.BusinessName, BusinessOwner = business.BusinessOwner, PhoneNumber = business.PhoneNumber, Email = business.Email, Website = business.Website, Logo = business.Logo, ABN = business.ABN, CustomerId = customer.CustomerId, Tax = (decimal)3.00, CustomerName = customer.CustomerName, CustomerAddress = customer.CustomerAddress, CustomerPhone = customer.CustomerPhoneNumber, CustomerEmail = customer.CustomerEmail, }; context.Invoices.Add(newInvoice); context.SaveChanges(); return(newInvoice.InvoiceNumber); } }
public static void DeleteBusiness(int id) { using (CustomerManagementSystemContext context = new CustomerManagementSystemContext()) { var business = new BusinessAccount(id); context.BusinessAccounts.Attach(business); context.BusinessAccounts.Remove(business); context.SaveChanges(); } }
public InvoiceDisplay NewInvoiceDisplay(int Id) { using (CustomerManagementSystemContext context = new CustomerManagementSystemContext()) { var invoice = new InvoiceDisplay(); var business = new BusinessAccount(Id); invoice.BusinessNumber = business.BusinessNumber; invoice.BusinessName = business.BusinessName; invoice.BusinessOwner = business.BusinessOwner; invoice.PhoneNumber = business.PhoneNumber; invoice.Email = business.Email; invoice.Website = business.Website; invoice.Logo = business.Logo; invoice.ABN = business.ABN; //Fill Customers up invoice.Customers = context.Customers.Where(x => x.BusinessNumber == Id).ToList(); return(invoice); } }