public void AddCustomer(Customer customer) { using (var context = new InoxicoHPContext(options.Options)) { context.Add(customer); context.SaveChanges(); } }
public void CustomerPaymentReceived(string paymentID) { using (var context = new InoxicoHPContext(options.Options)) { var customer = context.Customer.FirstOrDefault(cst => cst.PaymentID == paymentID); customer.PaymentReceived = true; context.Update(customer); context.SaveChanges(); } }
public string GenerateCustomerPaymentID(int customerID) { using (var context = new InoxicoHPContext(options.Options)) { var customer = context.Customer.FirstOrDefault(cst => cst.Id == customerID); if (customer == null) { return(""); } const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; string paymentID = new string(Enumerable.Repeat(chars, 32) .Select(s => s[random.Next(s.Length)]).ToArray()); customer.PaymentID = paymentID; context.Update(customer); context.SaveChanges(); return(paymentID); } }