コード例 #1
0
        public GalleryPhotoTagModel ShowPhotoByTag(IList <int> ids)
        {
            var tags = GetAll().Where(x => ids.Contains(x.Id)).ToList().Select(x => x.Id);

            var photos = _providerPhoto.GetAll().Where(x =>
                                                       _providerPhotoToTag.GetAll().Where(t => tags.Contains(t.TagId)).Select(r => r.PhotoId).Contains(x.Id));

            if (photos.Count() > 0)
            {
                var model = new GalleryPhotoTagModel()
                {
                    //TagName = CultureHelper.IsEnCulture() ? tag.TitleEng : tag.TitleRu,
                    Photos = photos.Select(x => new GalleryPhotoModel()
                    {
                        Id        = x.Id,
                        Thumbnail = x.ThumbnailPath,
                        Photo     = x.PhotoPath
                    })
                };

                return(model);
            }

            return(new GalleryPhotoTagModel());
        }
コード例 #2
0
        public ActionResult Tag(int id)
        {
            var tag    = _tagService.GetOne(id);
            var photos = _photoService.GetAll().Where(x =>
                                                      _photoToTagService.GetAll().Where(t => t.TagId == id).Select(r => r.PhotoId).Contains(x.Id));

            if (photos.Count() > 0)
            {
                var model = new GalleryPhotoTagModel()
                {
                    TagName = CultureHelper.IsEnCulture() ? tag.TitleEng : tag.TitleRu,
                    Photos  = photos.Select(x => new GalleryPhotoModel()
                    {
                        Id        = x.Id,
                        Thumbnail = x.ThumbnailPath,
                        Photo     = x.PhotoPath
                    })
                };

                return(View("~/Views/Gallery/TagRenderPattern.cshtml", model));
            }
            else
            {
                return(View(new GalleryPhotoListModel()));
            }
        }