示例#1
0
        public async Task OnGetAsync()
        {
            TvProgramSelectList = new SelectList(await _tvProgramService.GetTvProgramsAsync(),
                                                 nameof(TvProgram.Id), nameof(TvProgram.Name));

            VideoSourceSelectList = new SelectList(await _videoSourceService.GetVideoSourcesAsync(),
                                                   nameof(VideoSource.Id), nameof(VideoSource.Name));

            ArticleSourceSelectList = new SelectList(await _articleSourceService.GetArticleSourcesAsync(),
                                                     nameof(ArticleSource.Id), nameof(ArticleSource.Name));

            CornerSelectList = new SelectList(await _cornerService.GetCornersAsync(),
                                              nameof(Corner.Id), nameof(Corner.Name));

            SpecificationIndexViewModel = await _specificationViewModelService.SearchSpecifications(Filter);
        }
示例#2
0
        public async Task <SpecificationViewModel> GetSpecificationViewModel(int specificationId)
        {
            var specification = await _specificationService.FindSpecificationAsync(specificationId);

            if (specification == null)
            {
                return(null);
            }

            var viewModel = _mapper.Map <Specification, SpecificationViewModel>(specification);

            var categories = await _categoryService.GetCategoriesAsync();

            viewModel.CategorySelectItems = categories.Select(x =>
                                                              new SelectListItem
            {
                Text     = x.Name,
                Value    = x.Id.ToString(),
                Selected = specification.SpecificationCategories
                           .Any(sv => sv.CategoryId == x.Id)
            }).ToList();

            var videoSources = await _videoSourceService.GetVideoSourcesAsync();

            viewModel.VideoSourceSelectItems = videoSources.Select(x =>
                                                                   new SelectListItem
            {
                Text     = x.Name,
                Value    = x.Id.ToString(),
                Selected = specification.SpecificationVideoSources
                           .Any(sv => sv.VideoSourceId == x.Id)
            }).ToList();

            var articleSources = await _articleSourceService.GetArticleSourcesAsync();

            viewModel.ArticleSourceSelectItems = articleSources.Select(x =>
                                                                       new SelectListItem
            {
                Text     = x.Name,
                Value    = x.Id.ToString(),
                Selected = specification.SpecificationArticleSources
                           .Any(sa => sa.ArticleSourceId == x.Id)
            }).ToList();

            return(viewModel);
        }