public IActionResult Create() { CustomerAccountPrefix prefix = new CustomerAccountPrefix(); Dictionary <string, string> customerType = prefix.GetDictionary(); SelectList selectListItems = new SelectList((IEnumerable)customerType, "Value", "Key"); ViewData["customerType"] = selectListItems; return(View()); }
public async Task <IActionResult> Create(Customer customer) { if (!ModelState.IsValid) { CustomerAccountPrefix prefix = new CustomerAccountPrefix(); Dictionary <string, string> customerType = prefix.GetDictionary(); SelectList selectListItems = new SelectList((IEnumerable)customerType, "Value", "Key"); ViewData["customerType"] = selectListItems; return(View(customer)); } // Create Customer if (customer.AccountNumber.Length == 2) { // Code Provided, Append Number customer.AccountNumber += DateTimeOffset.Now.ToUnixTimeSeconds(); } _context.Customers.Add(customer); await _context.SaveChangesAsync(); TempData["Success"] = "Customer Created Successfully"; return(RedirectToAction(nameof(Index))); }