public RegisterViewModel Create()
        {
            var viewModel = new RegisterViewModel();

            var countries = getCountryListQuery.Execute();

            viewModel.Countries = countries
                                  .Select(c => new SelectListItem
            {
                Value = c.Id.ToString(),
                Text  = c.Name
            });

            return(viewModel);
        }
Ejemplo n.º 2
0
        public CreatePieceViewModel Create(string userId)
        {
            var museum = museumQuery.Execute(userId);

            var viewModel = new CreatePieceViewModel
            {
                Piece = new CreatePieceModel()
            };

            var media = mediumListQuery.Execute(museum.Id);

            viewModel.Media = media
                              .Select(m => new SelectListItem
            {
                Value = m.Id.ToString(),
                Text  = m.Name
            });

            var genres = genreListQuery.Execute(museum.Id);

            viewModel.Genres = genres
                               .Select(g => new SelectListItem
            {
                Value = g.Id.ToString(),
                Text  = g.Name
            });

            var subgenres = subgenreListQuery.Execute(museum.Id);

            viewModel.Subgenres = subgenres
                                  .Select(s => new SelectListItem
            {
                Value = s.Id.ToString(),
                Text  = s.Name
            });

            var subjectMatters = subjectMatterListQuery.Execute(museum.Id);

            viewModel.SubjectMatters = subjectMatters
                                       .Select(s => new SelectListItem
            {
                Value = s.Id.ToString(),
                Text  = s.Name
            });

            var locations = locationListQuery.Execute(museum.Id);

            viewModel.Locations = locations
                                  .Select(l => new SelectListItem
            {
                Value = l.Id.ToString(),
                Text  = l.Name
            });

            var countries = countryListQuery.Execute();

            viewModel.Countries = countries
                                  .Select(c => new SelectListItem
            {
                Value = c.Id.ToString(),
                Text  = c.Name
            }).ToList();

            var unitsOfMeasure = unitOfMeasureListQuery.Execute();

            viewModel.UnitsOfMeasure = unitsOfMeasure
                                       .Select(u => new SelectListItem
            {
                Value = u.Id.ToString(),
                Text  = u.Abbreviation
            });

            var artists = artistListQuery.Execute(museum.Id);

            viewModel.Artists = artists
                                .Select(a => new SelectListItem
            {
                Value = a.Id.ToString(),
                Text  = string.IsNullOrWhiteSpace(a.AlsoKnownAs) ? a.Name : string.Format("{0} aka \"{1}\"", a.Name, a.AlsoKnownAs)
            });

            var acquisitions = acquisitionListQuery.Execute(museum.Id);

            viewModel.Acquisitions = acquisitions
                                     .Select(a => new SelectListItem
            {
                Value = a.Id.ToString(),
                Text  = a.Date?.ToString("MM/dd/yyyy") + " " + a.PieceSource
            });

            var pieceSources = pieceSourceListQuery.Execute(museum.Id);

            viewModel.PieceSources = pieceSources
                                     .Select(p => new SelectListItem
            {
                Value = p.Id.ToString(),
                Text  = p.Name
            });

            var fundingSources = fundingSourceListQuery.Execute(museum.Id);

            viewModel.FundingSources = fundingSources
                                       .Select(f => new SelectListItem
            {
                Value = f.Id.ToString(),
                Text  = f.Name
            });

            var collections = collectionListQuery.Execute(museum.Id);

            viewModel.Collections = collections
                                    .Select(c => new SelectListItem
            {
                Value = c.Id.ToString(),
                Text  = c.Name
            });

            return(viewModel);
        }