public bool EventCount(int id) { Event eventos = _context.Events.Find(id); if (eventos.MaxParticipants == eventos.numbParticipants) { eventos.waitEvent = false; eventos.confirmEvent = true; _context.SaveChanges(); return(true); } return(false); }
public async Task <ActionResult <UserEvent> > DeleteUserEvent(string UserId) { var userEvent = await _context.UserEvents .Include(u => u.Event) .Include(u => u.User) .FirstOrDefaultAsync(m => m.UserId.Contains(UserId)); _context.UserEvents.Remove(userEvent); await _context.SaveChangesAsync(); int idEvent = userEvent.EventId; Event eventos = _context.Events.Find(idEvent); eventos.numbParticipants -= 1; eventos.confirmEvent = false; eventos.waitEvent = true; _context.SaveChanges(); return(userEvent); }