Exemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync(int id)
        {
            var user = await _userManager.GetUserAsync(User);

            _logger.LogInformation($"User {user.Id} registered for event {id}");
            var enrollment = new RideRegistration {
                RideEventID = id, InTandemUserID = user.Id
            };
            await _context.RideRegistration.AddAsync(enrollment);

            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnPostYesAsync(int?id)
        {
            var RideEvent = await _context.RideEvent
                            .AsNoTracking()
                            .FirstOrDefaultAsync(m => m.ID == id);

            await GetCurrentUser();

            if (InTandemUser != null && (RideEvent != null))
            {
                RideRegistration = new RideRegistration
                {
                    InTandemUserID = InTandemUser.Id,
                    RideEventID    = RideEvent.ID
                };
            }
            _context.RideRegistration.Add(RideRegistration);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }