public IEnumerable <TournamentViewModel> Get([FromQuery] PagingParameters pagingParameters) { var mapper = config.CreateMapper(); var tournaments = tournamentService.Get(pagingParameters.PageSize, pagingParameters.PageNumber); return(mapper.Map <List <TournamentDTO>, List <TournamentViewModel> >(tournaments)); }
/// <summary> /// Gets details for specific tournament /// </summary> /// <param name="id">Tournament id</param> /// <returns>View with specific tournament</returns> public ActionResult Details(int id) { var tournament = _tournamentService.Get(id); if (tournament == null) { return(HttpNotFound()); } var tournamentViewModel = TournamentViewModel.Map(tournament); tournamentViewModel.Authorization = _authService.GetAllowedOperations(new List <AuthOperation> { AuthOperations.Tournaments.Edit, AuthOperations.Tournaments.ManageTeams, AuthOperations.Tournaments.Archive }); return(View(tournamentViewModel)); }
/// <summary> /// Tournament's details /// </summary> /// <param name="id"> Tournament id</param> /// <returns> The <see cref="ActionResult"/>.</returns> public ActionResult TournamentDetails(int id) { var tournament = _tournamentService.Get(id); if (tournament == null) { return(HttpNotFound()); } var tournamentViewModel = TournamentViewModel.Map(tournament); return(View(tournamentViewModel)); }
public async Task <IActionResult> Get(int id) { var tournament = await _tournamentService.Get(id); return(Json(Mapper.Map <Tournament, TournamentViewModel>(tournament))); }
/// <summary> /// Gets all tournaments /// </summary> /// <returns>Collection of all tournaments</returns> public IEnumerable <TournamentViewModel> GetAllTournaments() { return(_tournamentService.Get().Select(t => TournamentViewModel.Map(t))); }
public void Run() { GoalscorersInExcel = new List <GoalscorerSync>(); GoalscorersToAdd = new List <Goalscorer>(); try { ConsoleMessage("/********************* Sync Goalscorers *********************/", ConsoleColor.DarkCyan); ConsoleMessage("Insert TournamentID: "); string strTournament = Console.ReadLine(); int tournamentId; if (!int.TryParse(strTournament, out tournamentId) || tournamentId <= 0) { ConsoleMessage("Tournament ID must be a number greater than 0", ConsoleColor.DarkRed, true); Run(); } ConsoleMessage("Retrieving tournament..", ConsoleColor.DarkMagenta); Tournament tournament = _tournamentService.Get(tournamentId).Result; if (tournament == null) { ConsoleMessage("Tournament not found", ConsoleColor.DarkRed, true); Run(); } ConsoleMessage(tournament.Name, ConsoleColor.DarkGreen); ConsoleMessage("Reading Excel file..", ConsoleColor.DarkMagenta); LoadExcelFile(); if (GoalscorersInExcel.Count <= 0) { ConsoleMessage("Excel file appears to be empty", ConsoleColor.DarkRed, true); Run(); } ConsoleMessage($"{GoalscorersInExcel.Count} goalscorers read", ConsoleColor.DarkGreen); CheckIfContinue(); ConsoleMessage("Processing file data..", ConsoleColor.DarkMagenta); ProcessData(tournament); if (GoalscorersToAdd.Count <= 0) { ConsoleMessage("No players were processed", ConsoleColor.DarkRed, true); Run(); } ConsoleMessage(GoalscorersToAdd.Count + " players processed", ConsoleColor.DarkGreen); CheckIfContinue(); ConsoleMessage("Saving..", ConsoleColor.DarkMagenta); try { _goalscorerService.Add(GoalscorersToAdd).Wait(); ConsoleMessage("Finished syncing goalscorers successfully", ConsoleColor.DarkGreen); } catch (Exception ex) { ConsoleMessage($"Error saving data: {ex.Message}", ConsoleColor.DarkRed); } ConsoleMessage("Press Enter to restart..", addNewLine: true); if (Console.ReadKey().Key == ConsoleKey.Enter) { Run(); } } catch (Exception ex) { ConsoleMessage($"Error: {ex.Message}", ConsoleColor.DarkRed); } }
public IEnumerable <TournamentViewModel> Get() { return(_tournamentService.Get().Select(TournamentViewModel.Map)); }
public IActionResult Get() { return(Ok(_tournamentService.Get())); }
public IActionResult Get(int id) { var result = _tournamentService.Get(id); return(Ok(_mapper.ToDTO(result))); }
public async Task <IActionResult> GetAll() { return(new OkObjectResult(await _tournamentService.Get())); }