public bool CreateRider(RiderCreate model) { var entity = new Rider() { OwnerId = _userId, FirstName = model.FirstName, LastName = model.LastName, Destination = model.Destination }; using (var ctx = new ApplicationDbContext()) { ctx.Riders.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(RiderCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateRiderService(); if (service.CreateRider(model)) { TempData["SaveResult"] = "Your ride has been requested!"; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Your ride could not be requested."); return(View(model)); }