コード例 #1
0
 private bool IsNullOrEmptyCacheData(WebBedsGetDataRequestDto dto)
 {
     if (dto == null || dto.HotelList == null || dto.Exceptions == null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #2
0
        //______________________________
        //We Get information of cache
        //______________________________
        private WebBedsGetDataRequestDto GetInformationFromMemoryCache(string key)
        {
            var webBedDataRequestDto = new WebBedsGetDataRequestDto();
            var exceptions           = new List <Exception>();

            try
            {
                webBedDataRequestDto = ApplicationCache.Cache.Get <WebBedsGetDataRequestDto>(key);
            }
            catch (Exception ex)
            {
                LogEnvironment.Instance.Add("Error GetInformationFromMemoryCache:" + GetExceptionString(ex));
                exceptions.Add(ex);
                webBedDataRequestDto.Exceptions = exceptions;
            }

            return(webBedDataRequestDto);
        }
コード例 #3
0
        //_______________________________________________________________________________________
        //This method realice the following actions:
        //  -Validate empthy params or not informed.
        //  -We search  the information in cache.If not is in cache we call to server repository
        //  -We tranform the information receibed
        //_______________________________________________________________________________________
        public WebBedsGetDataQueryResult ExecuteQuery(WebBedsGetDataQuery dto)
        {
            try
            {
                if (dto == null || dto.DestinationId == 0)
                {
                    return(null);
                }

                if (dto.NumNights <= 0)
                {
                    dto.NumNights = 1;
                }

                var webBedDataRequestList = new WebBedsGetDataRequestDto();

                //We find an information first in cache memory
                var key = dto.DestinationId.ToString() + "_" + dto.NumNights.ToString();

                webBedDataRequestList = GetInformationFromMemoryCache(key);

                if (IsNullOrEmptyCacheData(webBedDataRequestList))
                {
                    webBedDataRequestList = GetDataWebBedFromWebApiService(dto);
                }

                if (webBedDataRequestList == null)
                {
                    return(null);
                }
                else if (webBedDataRequestList.HotelList != null && webBedDataRequestList.HotelList.Count() > 0)
                {
                    ApplicationCache.Cache.Set(key, webBedDataRequestList);
                }

                //We call the translate function  to return our dto from domain objects list
                return(WebBedsGetDataAppTranslator.Instance.Translate(webBedDataRequestList));
            }
            catch (Exception ex)
            {
                LogEnvironment.Instance.Add("Error WebBedsGetDataQueryHandler:" + GetExceptionString(ex));
                throw;
            }
        }
コード例 #4
0
        //__________________________________________________
        //We get the information from web api repository
        //__________________________________________________
        private WebBedsGetDataRequestDto GetDataWebBedFromWebApiService(WebBedsGetDataQuery dto)
        {
            var resultDataList = new List <HotelAggregate>();
            var exceptionList  = new List <Exception>();

            var webBedDataRequestDto = new WebBedsGetDataRequestDto();

            try
            {
                var result = _webBedsWebApiRepository.GetData(dto.DestinationId, dto.NumNights);
                //resultDataList.AddRange(result);
                resultDataList = result.ToList();
            }
            catch (Exception ex)
            {
                exceptionList.Add(ex);
            }

            webBedDataRequestDto.HotelList  = resultDataList;
            webBedDataRequestDto.Exceptions = exceptionList;

            return(webBedDataRequestDto);
        }