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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }