public async Task <ActionResult> CustomersDelete(int customerAuditorID, string userID) { CustomerAuditor customerAuditor = await customerAuditorRepository.FindByIdAsync(customerAuditorID); if (customerAuditor == null) { return(HttpNotFound()); } var model = new EditAssignCustomerViewModel(customerAuditor); return(View(model)); }
public async Task <ActionResult> CustomersCreate(EditAssignCustomerViewModel model) { if (ModelState.IsValid) { CustomerAuditor customer = (CustomerAuditor)model.GetCustomer(); customer.UserId = model.UserID; try { await customerAuditorRepository.CreateAsync(customer); return(RedirectToAction("AssignedCustomers", "CustomerAdminAuditors", new { userID = model.UserID })); } catch (Exception e) { var errors = string.Join(",", e.Message); ModelState.AddModelError(string.Empty, errors); } } ViewBag.CustomerID = new SelectList(customerRepository.UnAssignedCustomers(model.UserID), "CustomerID", "CompanyName"); // If we got this far, something failed, redisplay form return(View(model)); }