// GET api/values
        ///[Filters.DeflateCompression]
        public async Task <List <GalleryViewModel> > Get()
        {
            //Mapping
            IList <string> list = new List <string> {
                "id"
            };
            var para = APIProvider.APIDefaultParameter(list, string.Empty);

            var source = await _gallery.Query(para);

            List <GalleryViewModel> dest = Mapper.Map <List <GalleryViewModel> >(source);

            return(dest);
        }
Esempio n. 2
0
        public async Task <IEnumerable <GalleryViewModel> > Query(byte departmentId = 0)
        {
            try
            {
                var results = await redisCache.GetListAsync <GalleryViewModel>("DepartmentId");

                if (results == null)
                {
                    List <string> list = new List <string> {
                        "Id", "DepartmentId"
                    };
                    Dictionary <string, dynamic> para = APIProvider.APIDefaultParameter(list, null, departmentId);
                    var source = await _iGalleryRepo.Query(para);

                    results = source.Select(s => new GalleryViewModel()
                    {
                        Id           = s.Id,
                        Title        = s.Title,
                        Description  = s.Description,
                        Highlight    = s.Highlight,
                        Img          = s.Img != null ? LayoutGuide.SPA_ResourcePath(Provider.Common.APIEnums.Application.CMS, s.Img) : null,
                        YoutubeURL   = s.YoutubeURL,
                        Date         = s.Date,
                        DepartmentId = s.DepartmentId,
                        IsMultiple   = s.IsMultiple
                    }).AsEnumerable();

                    //
                    await redisCache.AddListAsync <GalleryViewModel>(results, "DepartmentId", "Id");

                    await redisCache.AddListAsync <GalleryViewModel>(results);
                }

                //List<GalleryViewModel> dest = Mapper.Map<List<GalleryViewModel>>(source);
                return(results);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }