コード例 #1
0
        private List <ClubListViewModel> GetClubsFromCmd(OleDbCommand cmd)
        {
            List <ClubListViewModel> clubs = new List <ClubListViewModel>();

            using (OleDbDataReader dbReader = cmd.ExecuteReader())
            {
                int _clubId   = dbReader.GetOrdinal("id");
                int _clubName = dbReader.GetOrdinal("club_name");
                int _website  = dbReader.GetOrdinal("website");
                int _twitter  = dbReader.GetOrdinal("twitter");
                int _facebook = dbReader.GetOrdinal("facebook");
                int _wikiUrl  = dbReader.GetOrdinal("wiki_url");
                int _favicon  = dbReader.GetOrdinal("favicon");

                while (dbReader.Read())
                {
                    ClubListViewModel club = new ClubListViewModel();

                    club.id       = dbReader.GetInt32(_clubId);
                    club.clubName = dbReader.GetString(_clubName);
                    club.website  = dbReader.GetString(_website);
                    club.twitter  = dbReader.GetString(_twitter);
                    club.facebook = dbReader.GetString(_facebook);
                    club.wikiUrl  = dbReader.GetString(_wikiUrl);
                    club.favicon  = dbReader.GetString(_favicon);

                    clubs.Add(club);
                }
            }

            return(clubs);
        }
コード例 #2
0
        public async Task <List <AirplaneSelectModel> > AircraftFilterGet(int?clubId)
        {
            _logger.LogInformation("AircraftFilterGet");
            List <AirplaneSelectModel> airplaneSelectModels = new List <AirplaneSelectModel>();



            GetClubsListQuery getClubsListQuery = new GetClubsListQuery(QueryBy.ID, "", clubId ?? 0);
            ClubListViewModel clubs             = await _mediator.Send(getClubsListQuery); // ((clubId == null || clubId == 0) ? _clubService.GetClubs() : _clubService.GetClubById((int)clubId));

            GetClubAircraftListQuery getClubAircraftListQuery = new GetClubAircraftListQuery(QueryBy.Name, (clubs == null || clubs.ClubViewModels.Count() == 0) ? "" : clubs.ClubViewModels.FirstOrDefault().Name, clubId ?? 0);

            var airplaneSelectListModel = await _mediator.Send(getClubAircraftListQuery);

            airplaneSelectModels.Add(new AirplaneSelectModel()
            {
                Id = 0, TailNumber = "All Airplanes"
            });
            airplaneSelectModels.AddRange(airplaneSelectListModel.AircraftList.Select(ar => new AirplaneSelectModel()
            {
                Id = ar.Id, TailNumber = ar.TailNumber
            }).ToList());


            return(airplaneSelectModels);
        }
コード例 #3
0
ファイル: PlayerRepository.cs プロジェクト: arbazw/ttkaart-v2
        private List <PlayerListViewModel> GetPlayersFromCmd(OleDbCommand cmd)
        {
            List <PlayerListViewModel> players = new List <PlayerListViewModel>();

            PlayerListViewModel player = null;

            using (OleDbDataReader dbReader = cmd.ExecuteReader())
            {
                int _playerName   = dbReader.GetOrdinal("list_name");
                int _playerNumber = dbReader.GetOrdinal("player_nr");
                int _wikiUrl      = dbReader.GetOrdinal("wiki_url");
                int _wikiActive   = dbReader.GetOrdinal("wiki_active");
                int _clubId       = dbReader.GetOrdinal("id");
                int _clubName     = dbReader.GetOrdinal("club_name");

                while (dbReader.Read())
                {
                    string playerNr = dbReader.GetString(_playerNumber);

                    if (player == null || !player.playerNr.Equals(playerNr))
                    {
                        player = new PlayerListViewModel();

                        player.playerName = dbReader.GetString(_playerName);
                        player.playerNr   = playerNr;
                        player.wikiUrl    = dbReader.GetString(_wikiUrl);
                        player.wikiActive = dbReader.GetBoolean(_wikiActive);

                        players.Add(player);
                    }

                    ClubListViewModel club = new ClubListViewModel();

                    club.id       = dbReader.GetInt32(_clubId);
                    club.clubName = dbReader.GetString(_clubName);

                    player.clubs.Add(club);
                }
            }

            return(players);
        }
コード例 #4
0
        public async Task <FilterModel> FilterViewModelPut([FromBody] FilterModel filterModel)
        {
            _logger.LogInformation("FilterModelPut");
            int?clubId = filterModel.ClubFilterApplied;
            IEnumerable <Aircraft> aircrafts;
            IEnumerable <Pilot>    pilots;
            GetClubsListQuery      getClubsListQuery = new GetClubsListQuery(QueryBy.ID, "", clubId ?? 0);
            ClubListViewModel      clubs             = await _mediator.Send(getClubsListQuery); // ((clubId == null || clubId == 0) ? _clubService.GetClubs() : _clubService.GetClubById((int)clubId));

            GetClubAircraftListQuery getClubAircraftListQuery = new GetClubAircraftListQuery(QueryBy.Name, (clubs == null || clubs.ClubViewModels.Count() == 0) ? "" : clubs.ClubViewModels.FirstOrDefault().Name, clubId ?? 0);
            GetClubMembersListQuery  getClubMembersListQuery  = new GetClubMembersListQuery(QueryBy.Name, (clubs == null || clubs.ClubViewModels.Count() == 0) ? "" : clubs.ClubViewModels.FirstOrDefault().Name, clubId ?? 0);
            var aircraftListModel = await _mediator.Send(getClubAircraftListQuery);

            filterModel.ClubSelects = clubs.ClubViewModels.Select(c => new ClubSelectModel()
            {
                Id = c.Id, ClubName = c.Name
            });
            filterModel.AirplaneSelects.Add(new AirplaneSelectModel()
            {
                Id = 0, TailNumber = "All Airplanes"
            });
            filterModel.AirplaneSelects.AddRange(aircraftListModel.AircraftList.Select(ar => new AirplaneSelectModel()
            {
                Id = ar.Id, TailNumber = ar.TailNumber
            }).ToList());
            var pilotSelectListModel = await _mediator.Send(getClubMembersListQuery);

            filterModel.PilotSelects.Add(new PilotSelectModel()
            {
                Id = 0, FirstName = "All Pilots"
            });
            filterModel.PilotSelects.AddRange(pilotSelectListModel.PilotSelectList);
            filterModel.ClubFilterApplied     = filterModel.ClubSelects.FirstOrDefault().Id;
            filterModel.AirplaneFilterApplied = filterModel.AirplaneSelects.FirstOrDefault().Id;
            filterModel.PilotFilterApplied    = filterModel.PilotSelects.FirstOrDefault().Id;

            return(filterModel);
        }
コード例 #5
0
        public async Task <FilterModel> GetFilters(int clubId)
        {
            _logger.LogInformation("GetFilters");
            FilterModel            filterModel = new FilterModel();
            IEnumerable <Aircraft> aircrafts;
            IEnumerable <Pilot>    pilots;
            GetClubsListQuery      getClubsListQuery = new GetClubsListQuery(QueryBy.ID, "", clubId);
            ClubListViewModel      clubs             = await _mediator.Send(getClubsListQuery);

            GetClubAircraftListQuery getClubAircraftListQuery = new GetClubAircraftListQuery(QueryBy.ID, "", clubId);
            GetClubMembersListQuery  getClubMembersListQuery  = new GetClubMembersListQuery(QueryBy.ID, "", clubId);
            var aircraftListModel = await _mediator.Send(getClubAircraftListQuery);

            filterModel.ClubSelects = clubs.ClubViewModels.Select(c => new ClubSelectModel()
            {
                Id = c.Id, ClubName = c.Name
            });
            filterModel.AirplaneSelects.Add(new AirplaneSelectModel()
            {
                Id = 0, TailNumber = "All Airplanes"
            });
            filterModel.AirplaneSelects.AddRange(aircraftListModel.AircraftList.Select(ar => new AirplaneSelectModel()
            {
                Id = ar.Id, TailNumber = ar.TailNumber
            }).ToList());
            var pilotSelectListModel = await _mediator.Send(getClubMembersListQuery);

            filterModel.PilotSelects.Add(new PilotSelectModel()
            {
                Id = 0, FirstName = "All Pilots"
            });
            filterModel.PilotSelects.AddRange(pilotSelectListModel.PilotSelectList);
            filterModel.ClubFilterApplied     = filterModel.ClubSelects.FirstOrDefault().Id;
            filterModel.AirplaneFilterApplied = filterModel.AirplaneSelects.FirstOrDefault().Id;
            filterModel.PilotFilterApplied    = filterModel.PilotSelects.FirstOrDefault().Id;

            return(filterModel);
        }
コード例 #6
0
        public async Task <List <PilotSelectModel> > PilotFilterGet(int?clubId)
        {
            _logger.LogInformation("PilotFilterGet");
            List <PilotSelectModel> pilotSelectModels = new List <PilotSelectModel>();



            GetClubsListQuery getClubsListQuery = new GetClubsListQuery(QueryBy.ID, "", clubId ?? 0);
            ClubListViewModel clubs             = await _mediator.Send(getClubsListQuery); // ((clubId == null || clubId == 0) ? _clubService.GetClubs() : _clubService.GetClubById((int)clubId));

            GetClubMembersListQuery getClubMembersListQuery = new GetClubMembersListQuery(QueryBy.Name, (clubs == null || clubs.ClubViewModels.Count() == 0) ? "" : clubs.ClubViewModels.FirstOrDefault().Name, clubId ?? 0);

            var pilotSelectListModel = await _mediator.Send(getClubMembersListQuery);

            pilotSelectModels.Add(new PilotSelectModel()
            {
                Id = 0, FirstName = "All Pilots"
            });
            pilotSelectModels.AddRange(pilotSelectListModel.PilotSelectList);


            return(pilotSelectModels);
        }
コード例 #7
0
ファイル: ClubsController.cs プロジェクト: bojbaj/SportsClub
        public ActionResult Index()
        {
            var model = new ClubListViewModel();

            return(View(model));
        }