コード例 #1
0
        public TeamEdit Build(int id)
        {
            var team = _teamService.Get(id);

            var sports   = MvcService.BuildSportsSelectList(_sportService.Get(), team.Sport != null ? team.Sport.Id : 0);
            var leagues  = MvcService.BuildLeaguesSelectList(_leagueService.Get(), team.League != null ? team.League.Id : 0);
            var colleges = MvcService.BuildCollegesSelectList(_collegeService.Get(), team.College != null ? team.College.Id : 0);

            var vm = new TeamEdit
            {
                DisplayName = team.ToString(),
                Sports      = sports,
                Leagues     = leagues,
                Colleges    = colleges,
                TeamVM      = new TeamViewModel
                {
                    Id          = team.Id,
                    Identifier  = team.Identifier,
                    City        = team.City,
                    Nickname    = team.Nickname,
                    NotableFlag = team.NotableFlag,
                    CollegeId   = team.College == null ? 0 : team.College.Id,
                    SportId     = team.Sport == null ? 0 : team.Sport.Id,
                    LeagueId    = team.League == null ? 0 : team.League.Id
                }
            };

            return(vm);
        }
コード例 #2
0
        public TeamIndex Build(TeamFilterOptionsViewModel filterOptionsVM)
        {
            var teamSearchFilterOptions = SearchFilterService.BuildTeamSearchFilterOptions(filterOptionsVM);

            if (teamSearchFilterOptions == null)
            {
                teamSearchFilterOptions = new TeamSearchFilterOptions();
            }
            var teamSearch = _teamSearchService.Get(teamSearchFilterOptions);
            var sports     = _sportService.Get();
            var leagues    = _leagueService.Get();
            var teamList   = teamSearch.Teams.Select(x => new TeamListItemViewModel
            {
                Id          = x.Id,
                Name        = x.ToString(),
                LeagueName  = x.League != null? x.League.Name : "",
                SportName   = x.Sport != null ? x.Sport.Name : "",
                CollegeId   = x.College != null ? x.College.Id : 0,
                CollegeName = x.College != null ? x.College.Name : ""
            })
                             .ToList();

            var teamSearchViewModel = new TeamIndex
            {
                TeamFilterOptionsViewModel = filterOptionsVM,
                Teams   = teamList,
                Sports  = MvcService.BuildSportsSelectList(sports, teamSearchFilterOptions.SportId ?? 0),
                Leagues = MvcService.BuildLeaguesSelectList(leagues, teamSearchFilterOptions.LeagueId ?? 0)
            };

            return(teamSearchViewModel);
        }
コード例 #3
0
        public PersonIndex Build(PersonFilterOptionsViewModel filterOptionsViewModel)
        {
            var personSearchFilterOptions = SearchFilterService.BuildPersonSearchFilterOptions(filterOptionsViewModel);

            if (personSearchFilterOptions == null)
            {
                personSearchFilterOptions = new PersonSearchFilterOptions();
            }
            var personSearch = _personSearchService.Get(personSearchFilterOptions);
            var teams        = _teamService.Get();

            var sports     = _sportService.Get();
            var leagues    = _leagueService.Get();
            var peopleList = personSearch.People.Select(x => new PersonListItemViewModel
            {
                Id          = x.Id,
                Name        = x.LastName == null ? string.Format("[{0}]", x.Identifier) : x.ToString(),
                CollegeId   = x.College != null ? x.College.Id : 0,
                CollegeName = x.College != null ? x.College.Name : "",
                SportNames  = x.Sports != null ? BuildSportNames(x.Sports) : "",
                HOFFlag     = x.HOFFlag == true ? "HOF" : "",
                HeismanFlag = x.HeismanFlag == true ? "Heisman" : "",
                NotableFlag = x.NotableFlag == true ? "Notable" : "",
            })
                             .ToList();

            var personSearchViewModel = new PersonIndex
            {
                PersonFilterOptionsViewModel = filterOptionsViewModel,
                People  = peopleList,
                Sports  = MvcService.BuildSportsSelectList(sports, personSearchFilterOptions.SportId ?? 0),
                Leagues = MvcService.BuildLeaguesSelectList(leagues, personSearchFilterOptions.LeagueId ?? 0),
                Teams   = MvcService.BuildTeamsSelectList(teams, personSearchFilterOptions.TeamId ?? 0)
            };

            return(personSearchViewModel);
        }
コード例 #4
0
        public SportDetails Build(int id, CardFilterOptionsViewModel filterOptionsVM, bool hasOwnerRights)
        {
            var leagues       = _leagueService.Get().Where(x => x.SportId == id).ToList();
            var defaultLeague = leagues.SingleOrDefault(x => x.SportId == id && x.SearchDefault);

            if (filterOptionsVM == null)
            {
                filterOptionsVM = new CardFilterOptionsViewModel
                {
                    SportId   = id,
                    PersonId  = 0,
                    CollegeId = 0,
                    TeamId    = 0,
                    LeagueId  = defaultLeague != null ? defaultLeague.Id : 0
                };
            }
            filterOptionsVM.SportId = id;

            var defaultFilterOptionsVM = new CardFilterOptionsViewModel
            {
                SportId   = id,
                PersonId  = 0,
                CollegeId = 0,
                TeamId    = 0,
                LeagueId  = defaultLeague != null ? defaultLeague.Id : 0
            };

            var cardFilterOptions    = SearchFilterService.BuildCardSearchFilterOptions(filterOptionsVM);
            var defaultFilterOptions = SearchFilterService.BuildCardSearchFilterOptions(defaultFilterOptionsVM);

            var sport = _sportService.Get(id);

            var cardSearch = _cardSearchService.Get(cardFilterOptions);
            var people     = _cardSearchService.GetPeople(defaultFilterOptions);
            var teams      = _cardSearchService.GetTeams(defaultFilterOptions);
            var colleges   = _cardSearchService.GetColleges(defaultFilterOptions);
            var grades     = _cardSearchService.GetGrades(defaultFilterOptions);
            var graders    = _cardSearchService.GetGraders(defaultFilterOptions);

            var cards = cardSearch.Cards
                        .Select(x => new CardListItemViewModel
            {
                Id             = x.Id,
                CardNumber     = x.CardNumber != null ? x.CardNumber.ToString() : "--",
                FormattedCost  = FormatService.FormatDollars(x.Cost),
                FormattedValue = FormatService.FormatDollars(x.Value),
                PersonName     = x.Person == null ? "" : x.Person.ToString(),
                PersonId       = x.Person == null ? 0 : x.Person.Id,
                TeamName       = x.Team == null ? "" : x.Team.ToString(),
                TeamId         = x.Team == null ? 0 : x.Team.Id,
                Company        = x.SetName,
                Grade          = x.Grade != null ? x.Grade.Name : "",
                GraderName     = x.Grade != null ? x.Grade.GraderName : "",
                RC             = x.RCFlag ? "RC" : "",
                HOF            = x.Person == null ? "" : x.Person.HOFFlag ? " (HOF)" : "",
                Year           = x.Year.ToString(),
                Attributes     = FormatService.BuildAttributes(x)
            })
                        .ToList();


            var sportDetailsViewModel = new SportDetails
            {
                Id             = sport.Id,
                Identifier     = sport.Identifier,
                DisplayName    = string.Format("{0} Cards", sport.Name),
                HasOwnerRights = hasOwnerRights,
                Cards          = cards,
                SearchTotalsVM = new SearchTotalsViewModel
                {
                    NumCollectibles = cardSearch.NumCards,
                    TotalCost       = cardSearch.TotalCost,
                    ShowTotalCost   = hasOwnerRights,
                    TotalValue      = cardSearch.TotalValue
                },
                FilterOptionsVM = new CardSearchViewModel
                {
                    ShowPeopleFilters = "",
                    ShowHeismanFilter = sport.Name == "Football" ? "" : "hidden",
                    People            = MvcService.BuildPeopleSelectList(people, cardFilterOptions.PersonId ?? 0),
                    Leagues           = MvcService.BuildLeaguesSelectList(leagues, cardFilterOptions.LeagueId ?? 0),
                    Teams             = MvcService.BuildTeamsSelectList(teams, cardFilterOptions.TeamId ?? 0),
                    Colleges          = MvcService.BuildCollegesSelectList(colleges, cardFilterOptions.CollegeId ?? 0),
                    Graders           = MvcService.BuildGradersSelectList(graders, cardFilterOptions.GraderId ?? 0),
                    Grades            = MvcService.BuildGradesSelectList(grades, cardFilterOptions.GradeId ?? 0),
                    MinValues         = MvcService.BuildValuesSelectList(cardFilterOptions.MinValue ?? 0),
                    MaxValues         = MvcService.BuildValuesSelectList(cardFilterOptions.MaxValue ?? 0)
                }
            };

            return(sportDetailsViewModel);
        }