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

            var source = await _feature.Query(para);

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

            return(dest);
        }
Example #2
0
        public async Task <HttpResponseMessage> Get()
        {
            try
            {
                var results = await redisCache.GetListAsync <FeatureViewModel>();

                if (results == null || results.Count() == 0)
                {
                    List <string> list = new List <string> {
                        "Id"
                    };
                    var para = APIProvider.APIDefaultParameter(list, 0);

                    var data = await _iFeatureRepo.Query(para);

                    var listFeatures = Mapper.Map <List <FeatureViewModel> >(data);
                    results = data.Select(s => new FeatureViewModel()
                    {
                        Id          = s.Id,
                        Title       = s.Title,
                        Image       = LayoutGuide.SPA_ResourcePath(Provider.Common.APIEnums.Application.CMS, s.Image),
                        Description = s.Description,
                        Handler     = s.Handler,
                        IsUsed      = s.IsUsed
                    }).AsEnumerable();

                    //
                    await redisCache.AddListAsync <FeatureViewModel>(results);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, results));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }