コード例 #1
0
        /// <summary>
        /// Return list of Beds
        /// </summary>
        /// <returns>Task<IActionResult></returns>
        public async Task <IActionResult> GetBed()
        {
            BaseResult <List <BedViewModel> > BedResult = new BaseResult <List <BedViewModel> >
            {
                Result = RedisCacheHelper.Instance.Get <List <BedViewModel> >(Helper.Constants.CacheKeys.BedList)
            };

            if (BedResult.Result == null || !BedResult.Result.Any())
            {
                BaseResult <List <Bed> > Bed = await iRoom.GetBed().ConfigureAwait(false);

                if (Bed.IsError && Bed.ExceptionMessage != null)
                {
                    return(StatusCode(500, Bed));
                }
                else if (Bed.Result == null || !Bed.Result.Any())
                {
                    return(NoContent()); //204
                }
                else
                {
                    var bedVm = DbMapperMasterdata.MapBedList(Bed); //mapping to BedViewModel
                    RedisCacheHelper.Instance.Set <List <BedViewModel> >(Helper.Constants.CacheKeys.BedList, bedVm.Result);
                    return(Ok(bedVm));                              //200
                }
            }
            return(Ok(BedResult));//200
        }