Ejemplo n.º 1
0
        public PhotoGalleryListModel PrePareGalleryListModel(PhotoGalleryPagingFilteringModel command)
        {
            var model = new  PhotoGalleryListModel();

            if (command.PageSize <= 0)
            {
                command.PageSize = 15;
            }

            if (command.PageNumber <= 0)
            {
                command.PageNumber = 1;
            }

            var galeries = _galleryService.GetAllPhotoGalleries(photoGaleryId: 3, pageIndex: command.PageNumber - 1, pageSize: command.PageSize);

            model.PhotoGalleryPagingFilteringModel.LoadPagedList(galeries);
            model.PhotoGalleryModels = galeries.Select(x =>
            {
                var photoGalleriModel = new PhotoGalleryModel();
                PreParePhotoGalleryModel(photoGalleriModel, x);
                return(photoGalleriModel);
            }).ToList();
            var galeri = _galleryService.GetPhotoGalleries().Where(x => x.Id != 3);

            model.GalleryModels = galeri.Select(x =>
            {
                var galleryModel = PrePareGalleryModel(x.Id);
                return(galleryModel);
            }).ToList();
            return(model);
        }
Ejemplo n.º 2
0
        public virtual IActionResult GalleryList(PhotoGallerySearchModel searchModel)
        {
            IQueryable <PhotoGallery> query = _photoGalleryRepository.Table;

            if (searchModel.SearchGalleryId != 0)
            {
                query = from g in query
                        join m in _photoGalleryMapRepository.Table on g.Id equals m.GalleryId
                        where m.GalleryId == searchModel.SearchGalleryId
                        select g;
            }

            if (!string.IsNullOrEmpty(searchModel.SearchName))
            {
                query = query.Where(x => x.Name.Contains(searchModel.SearchName));
            }

            List <PhotoGallery>      pagelists = query.ToList();
            PagedList <PhotoGallery> pageList  = new PagedList <PhotoGallery>(pagelists, searchModel.Page - 1, searchModel.PageSize);
            PhotoGalleryListModel    model     = new PhotoGalleryListModel
            {
                Data = pageList.PaginationByRequestModel(searchModel).Select(x =>
                {
                    PhotoGalleryModel galerModel = new PhotoGalleryModel
                    {
                        Id           = x.Id,
                        Name         = x.Name,
                        DisplayOrder = x.DisplayOrder,
                        Published    = x.Published
                    };
                    return(galerModel);
                }),
                Total = pageList.Count
            };

            return(Json(model));
        }