public async Task <IActionResult> Register([Bind("CustomerId,UserName,FirstName,LastName,Password,DateAdded")] Customer customer) { /// <summary> /// Registers a new customer /// </summary> if (ModelState.IsValid) { Customer checkCust = UtilMethods.GetCustomerByUserName(customer.UserName, _context); if (checkCust.UserName != null) { System.Diagnostics.Debug.WriteLine($"Customer with user name {customer.UserName} already exists"); return(Redirect("/Login/Register?warn=duplicate")); } else { customer.DateAdded = DateTime.Now; _context.Add(customer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } return(View(customer)); }