public ActionResult NewDriver(DriverPageViewModel viewModel) { Trace.WriteLine("posted"); if (string.IsNullOrEmpty(viewModel.Name) || string.IsNullOrEmpty(viewModel.Name)) { viewModel.ErrorMessage = "Please provide the driver's name"; return View(viewModel); } User thisuser = _context.getUser(SimpleSessionPersister.Username); var newdriver = new Driver { Name = viewModel.Name, Company = thisuser.Organization }; Trace.WriteLine("posted"); _context.Drivers.Add(newdriver); _context.SaveChanges(); return RedirectToAction("Drivers", "SMJob"); }
public ActionResult NewDriver() { var vm = new DriverPageViewModel { Name = "Name", RouteNumber = "RouteNumber" }; return View(vm); }