public IActionResult Get(Guid id) { var mapper = config.CreateMapper(); var tournament = tournamentService.Find(id); if (tournament == null) { return(NotFound()); } var tournamentViewModel = mapper.Map <TournamentDTO, TournamentViewModel>(tournament); tournamentViewModel.Prizes = mapper.Map <List <PrizeDTO>, List <PrizeViewModel> >(tournament.Prizes); return(new JsonResult(tournamentViewModel)); }
public IActionResult delete(int?tournamentId) { try { var dbRecord = _tournamentService.Find(tournamentId); if (tournamentId.HasValue) { if (dbRecord != null) { _logger.LogInformation($"Record {tournamentId} deleted"); _tournamentService.Delete(tournamentId); return(Ok("Record deleted")); } else { return(BadRequest("Record copuld not be deleted please try agin")); } } else { return(NotFound("Record not found")); } } catch (Exception ex) { _logger.LogInformation("Api delete request failed", ex); return(BadRequest("Record could not be deleted")); } }