public CollegeDetails Build(int id, CardFilterOptionsViewModel filterOptionsVM, bool hasOwnerRights)
        {
            if (filterOptionsVM == null)
            {
                filterOptionsVM = new CardFilterOptionsViewModel();
            }
            filterOptionsVM.CollegeId = id;


            var defaultFilterOptionsVM = new CardFilterOptionsViewModel
            {
                CollegeId = id
            };

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

            var college    = _collegeService.Get(id);
            var cardSearch = _cardSearchService.Get(cardFilterOptions);
            var people     = _cardSearchService.GetPeople(defaultFilterOptions);
            var teams      = _cardSearchService.GetTeams(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,
                Grade          = x.Grade == null ? "" : x.Grade.Name,
                Company        = x.SetName,
                RC             = x.RCFlag ? "RC" : "",
                HOF            = x.Person != null ? x.Person.HOFFlag ? "(HOF)" : "" : "",
                Year           = x.Year.ToString(),
                Attributes     = FormatService.BuildAttributes(x)
            })
                             .ToList();

            var collegeViewModel = new CollegeDetails
            {
                Id             = college.Id,
                Identifier     = college.Identifier,
                DisplayName    = college.ToString(),
                HasOwnerRights = hasOwnerRights,
                Cards          = cards,
                SearchTotalsVM = new SearchTotalsViewModel
                {
                    NumCollectibles = cardSearch.NumCards,
                    TotalCost       = cardSearch.TotalCost,
                    ShowTotalCost   = hasOwnerRights,
                    TotalValue      = cardSearch.TotalValue
                },
                FilterOptionsVM = new CardSearchViewModel
                {
                    People        = MvcService.BuildPeopleSelectList(people, filterOptionsVM.PersonId),
                    Teams         = MvcService.BuildTeamsSelectList(teams, filterOptionsVM.TeamId),
                    FilterOptions = filterOptionsVM
                }
            };

            return(collegeViewModel);
        }
        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);
        }
        public PersonDetails Build(int id, CardFilterOptionsViewModel filterOptionsVM, bool hasOwnerRights)
        {
            if (filterOptionsVM == null)
            {
                filterOptionsVM = new CardFilterOptionsViewModel();
            }
            filterOptionsVM.PersonId = id;

            var defaultFilterOptionsVM = new CardFilterOptionsViewModel
            {
                PersonId = id
            };

            if (filterOptionsVM == null)
            {
                filterOptionsVM = defaultFilterOptionsVM;
            }
            var cardFilterOptions    = SearchFilterService.BuildCardSearchFilterOptions(filterOptionsVM);
            var defaultFilterOptions = SearchFilterService.BuildCardSearchFilterOptions(defaultFilterOptionsVM);

            var person     = _personService.Get(id);
            var cardSearch = _cardSearchService.Get(cardFilterOptions);
            var teams      = _cardSearchService.GetTeams(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,
                Grade          = x.Grade == null ? "" : x.Grade.Name,
                Company        = x.SetName,
                RC             = x.RCFlag ? "RC" : "",
                HOF            = x.Person == null ? "" : x.Person.HOFFlag ? "HOF" : "",
                Year           = x.Year.ToString(),
                CardType       = x.CardType == null ? "" : x.CardType.Name == "Player" ? "" : x.CardType.Name,
                Attributes     = FormatService.BuildAttributes(x)
            })
                             .ToList();

            var displayName = person.Name;

            if (person.HOFFlag)
            {
                displayName += " (HOF)";
            }

            var personDetailsViewModel = new PersonDetails
            {
                Id             = person.Id,
                Identifier     = person.Identifier,
                Cards          = cards,
                DisplayName    = displayName,
                HasOwnerRights = hasOwnerRights,
                SearchTotalsVM = new SearchTotalsViewModel
                {
                    NumCollectibles = cardSearch.NumCards,
                    TotalCost       = cardSearch.TotalCost,
                    TotalValue      = cardSearch.TotalValue
                },
                FilterOptionsVM = new CardSearchViewModel
                {
                    Teams             = MvcService.BuildTeamsSelectList(teams, cardFilterOptions.TeamId ?? 0),
                    MinValues         = MvcService.BuildValuesSelectList(cardFilterOptions.MinValue ?? 0),
                    MaxValues         = MvcService.BuildValuesSelectList(cardFilterOptions.MaxValue ?? 0),
                    ShowPeopleFilters = "hidden",
                    FilterOptions     = filterOptionsVM
                }
            };

            return(personDetailsViewModel);
        }
Example #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);
        }