public async Task <IActionResult> Update([FromBody] TicketForBuyingDTO model, [FromQuery] string username) { var tickets = _ticketService.GetAvailableByMatchId(model.matchid); if (!tickets.Any()) { return(NotFound()); } var user = await _usersService.Get(username); var index = 1; foreach (Ticket ticket in tickets) { if (index > model.amount) { break; } ticket.status = 0; user.tickets.Add(ticket.Id); _ticketService.Update(ticket.Id, ticket); index = index + 1; } _usersService.Update(username, user); return(NoContent()); }
public ActionResult <List <Match> > Get() { var all_matches = _matchService.Get(); foreach (Match match in all_matches) { var tickets = _ticketsService.GetAvailableByMatchId(match.Id); /*if(!tickets.Any()) * { * all_matches.Remove(match); * } */ match.ticketCount = tickets.Count; } return(all_matches); }