public async Task <IActionResult> EditPost(int?id) { if (id == null) { return(NotFound()); } var riderToUpdate = await _context.Riders.SingleOrDefaultAsync(r => r.ID == id); if (await TryUpdateModelAsync <Rider>( riderToUpdate, "", r => r.FirstName, r => r.LastName, r => r.PhoneNumber, r => r.EmailAddress, r => r.Role)) { try { await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log.) ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists, " + "see your system administrator."); } } return(View(riderToUpdate)); }
public async Task <IActionResult> Create([Bind("ID,RideName,Description,StartDate,Distance")] Ride ride) { if (ModelState.IsValid) { ride.CreatorId = 0; _context.Add(ride); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(ride)); }
public async Task <IActionResult> Create([Bind("Id,FollowingId,FollowerId,FollowState")] Follow follow) { if (ModelState.IsValid) { _context.Add(follow); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(follow)); }
public async Task <IActionResult> Create([Bind("SignupID,RideID,RiderID")] Signup signup) { if (ModelState.IsValid) { _context.Add(signup); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["RideID"] = new SelectList(_context.Rides, "ID", "Description", signup.RideID); ViewData["RiderID"] = new SelectList(_context.Riders, "ID", "EmailAddress", signup.RiderID); return(View(signup)); }