public static CustomerInformation CreateCustomerInformation(string customerName, string customerEmailAddress, string customerAddress) { using (var db = new CustomerModel()) { if (!accountsLoaded) { //This increments based on the count of rows. lastAccountNumber = db.CustomerInformations.Count(); accountsLoaded = true; } CustomerInformation customerAccount = new CustomerInformation(); customerAccount.CustomerName = customerName; customerAccount.EmailAddress = customerEmailAddress; customerAccount.Address = customerAddress; customerInformations.Add(customerAccount); db.CustomerInformations.Add(customerAccount); db.SaveChanges(); return customerAccount; } }
public static CustomerInformation[] GetAllCustomerInformationByEmail(string emailAddress) { using (var db = new CustomerModel()) { var customerInfo = db.CustomerInformations.Where(info => info.EmailAddress.ToLower() == emailAddress); return customerInfo.ToArray(); } }