Exemplo n.º 1
0
        /// <summary>
        /// Return list of Size Measures
        /// </summary>
        /// <returns>Task<IActionResult></returns>
        public async Task <IActionResult> GetSizeMeasure()
        {
            BaseResult <List <SizeMeasureViewModel> > SizeMeasureResult = new BaseResult <List <SizeMeasureViewModel> >
            {
                Result = RedisCacheHelper.Instance.Get <List <SizeMeasureViewModel> >(Helper.Constants.CacheKeys.SizeMeasureList)
            };

            if (SizeMeasureResult.Result == null || !SizeMeasureResult.Result.Any())
            {
                BaseResult <List <SizeMeasure> > sizeMeasure = await iRoom.GetSizeMeasure().ConfigureAwait(false);

                if (sizeMeasure.IsError && sizeMeasure.ExceptionMessage != null)
                {
                    return(StatusCode(500, sizeMeasure));
                }
                else if (sizeMeasure.Result == null || !sizeMeasure.Result.Any())
                {
                    return(NoContent()); //204
                }
                else
                {
                    var sizeMeasureVm = DbMapperMasterdata.MapSizeMeasureList(sizeMeasure); //mapping to SizeMeasureViewModel
                    RedisCacheHelper.Instance.Set <List <SizeMeasureViewModel> >(Helper.Constants.CacheKeys.SizeMeasureList, sizeMeasureVm.Result);
                    return(Ok(sizeMeasureVm));                                              //200
                }
            }
            return(Ok(SizeMeasureResult));//200
        }