コード例 #1
0
        public async Task <HttpResponseMessage> Get(byte id)
        {
            var result = await redisCache.GetAsync <FeatureViewModel>(id);

            if (result == null)
            {
                List <string> list = new List <string> {
                    "Id"
                };
                var para = APIProvider.APIDefaultParameter(list, id);

                var data = await _iFeatureRepo.SingleQuery(para);

                result = new FeatureViewModel
                {
                    Id          = data.Id,
                    Title       = data.Title,
                    Image       = LayoutGuide.SPA_ResourcePath(Provider.Common.APIEnums.Application.CMS, data.Image),
                    Description = data.Description,
                    Handler     = data.Handler,
                    IsUsed      = data.IsUsed
                };

                //
                await redisCache.AddAsync <FeatureViewModel>(result);
            }


            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
コード例 #2
0
        /// <summary>
        /// Get by Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Category view model</returns>
        // GET api/values/5
        public async Task <FeatureViewModel> GetById(byte id)
        {
            var list = this.RequestContext.RouteData.Values.Keys;
            var para = APIProvider.APIGeneratorParameter(list, id);

            var source = await _feature.SingleQuery(para);

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

            return(dest);
        }