public async Task <PartialViewResult> OnPostCustomerPhonesUpdateAsync(CustomerPhonesEdit phone) { if (ModelState.IsValid) { switch (phone.Action) { case "Create": _context.CustomerPhones.Add(phone.CustomerPhone); //TODO: Reserve Twilio Number //TODO: Configure Inbound webhooks break; case "Edit": _context.CustomerPhones.Update(phone.CustomerPhone); break; case "Delete": _context.CustomerPhones.Remove(phone.CustomerPhone); //TODO: Cancel Twilio Phone break; } await _context.SaveChangesAsync(); } return(CustomerPhonesModal(phone)); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Customers).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomersExists(Customers.CustomerId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./CustomerIndex")); }
public async Task <PartialViewResult> OnPostCustomersUpdate(Models.Customers customer) { if (ModelState.IsValid) { switch (customer.Action) { case "Create": customer.FTPUserName = customer.CustomerCode; customer.FTPPassword = GenerateRandomPassword(); //TODO: Create Twilio Subaccount //TODO: Get SendGridAPIKey and populate, generate e-mail address _context.Customers.Add(customer); await _context.SaveChangesAsync(); Models.MasterRates masterrate = _context.MasterRates.FirstOrDefault(mr => mr.IsMember == customer.IsMember); Models.CustomerRates rate = new Models.CustomerRates { CustomerId = customer.CustomerId, EmailRate = masterrate.EmailRate, TextRate = masterrate.TextRate, VoiceRate = masterrate.VoiceRate }; _context.CustomerRates.Add(rate); break; case "Edit": //Not used here break; case "Delete": _context.Customers.Remove(customer); //TODO: Close Twilio Subaccount //TODO: Cancel Twilio Phone break; } await _context.SaveChangesAsync(); } return(GetCustomersModal(customer)); }