Beispiel #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);
        }
        public PersonEdit Build(int id)
        {
            var person = _personService.Get(id);


            var sportIds = person.Sports.Select(x => x.Id).ToList();

            int collegeId = 0;

            if (person.College != null)
            {
                collegeId = person.College.Id;
            }

            var colleges = _collegeService.Get();
            var sports   = _sportService.Get();

            var collegesSelectList = MvcService.BuildCollegesSelectList(colleges, collegeId);
            var sportSelectList    = MvcService.BuildSportsSelectList(sports, 0, "");

            var vm = new PersonEdit
            {
                DisplayName = person.ToString(),
                Colleges    = collegesSelectList,
                Sports      = sportSelectList,
                PersonVM    = new PersonViewModel
                {
                    Id          = person.Id,
                    Identifier  = person.Identifier,
                    LastName    = person.LastName,
                    FirstName   = person.FirstName,
                    MiddleName  = person.MiddleName,
                    Suffix      = person.Suffix,
                    HOFFlag     = person.HOFFlag,
                    HeismanFlag = person.HeismanFlag,
                    NotableFlag = person.NotableFlag,
                    CollegeId   = collegeId,
                    SportIds    = sportIds
                }
            };

            return(vm);
        }
        public ProductDetails Build(int id, CardFilterOptionsViewModel filterOptionsVM, bool hasOwnerRights)
        {
            if (filterOptionsVM == null)
            {
                filterOptionsVM = new CardFilterOptionsViewModel
                {
                    ProductId = id,
                    PersonId  = 0,
                    CollegeId = 0,
                    TeamId    = 0,
                    LeagueId  = 0
                };
            }
            filterOptionsVM.ProductId = id;

            var defaultFilterOptionsVM = new CardFilterOptionsViewModel
            {
                ProductId = id,
                PersonId  = 0,
                CollegeId = 0,
                TeamId    = 0,
                LeagueId  = 0
            };

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

            var product = _productService.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 productDetailsViewModel = new ProductDetails
            {
                Id             = product.Id,
                Identifier     = product.Identifier,
                DisplayName    = product.Name,
                Price          = product.Price,
                HasOwnerRights = false,   // need to revisit this
                Cards          = cards,
                SearchTotalsVM = new SearchTotalsViewModel
                {
                    NumCollectibles = cardSearch.NumCards,
                    TotalCost       = cardSearch.TotalCost,
                    TotalValue      = cardSearch.TotalValue
                },
                FilterOptionsVM = new CardSearchViewModel
                {
                    ShowPeopleFilters = "",
                    ShowHeismanFilter = product.Name == "Football" ? "" : "hidden",
                    People            = MvcService.BuildPeopleSelectList(people, cardFilterOptions.PersonId ?? 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(productDetailsViewModel);
        }
Beispiel #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);
        }