Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            JoinedEvent = await _context.JoinedEvents.FindAsync(id);

            if (JoinedEvent != null)
            {
                _context.Events.Where(e => e.EventID == JoinedEvent.EventID).First().SpotsAvailable++;
                _context.JoinedEvents.Remove(JoinedEvent);
                await _context.SaveChangesAsync();
            }
            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (id == null)
            {
                return(NotFound());
            }

            JoinedEvent.Attendee = await _context.Attendees.Where(a => a.AttendeeID == 1).FirstOrDefaultAsync();

            JoinedEvent.Event = await _context.Events.Where(e => e.EventID == id).FirstOrDefaultAsync();

            _context.JoinedEvents.Add(JoinedEvent);
            _context.Events.Where(e => e.EventID == id).First().SpotsAvailable--;

            await _context.SaveChangesAsync();

            return(RedirectToPage("./Details", new { id = id }));
        }