Example #1
0
        public IEnumerable <WeatherForecast> Get()
        {
            _logger.LogInformation("hello world");
            var rng = new Random();

            List <WeatherForecast> result = new List <WeatherForecast>();

            try
            {
                int a = 1;
                int b = 0;
                if (a / b == 0)
                {
                }
            }
            catch (Exception ex)
            {
            }

            var list = _cachingService.GetList <WeatherForecast>("data");

            if (list == null)
            {
                result = Enumerable.Range(1, 5).Select(index => new WeatherForecast
                {
                    Date         = DateTime.Now.AddDays(index),
                    TemperatureC = rng.Next(-20, 55),
                    Summary      = Summaries[rng.Next(Summaries.Length)]
                }).ToList();

                _cachingService.Set(result, "data", 1);
            }
            else
            {
                result = list;
            }
            return(result);
        }
Example #2
0
        public async Task <ResponseModel> DropDownSelection()
        {
            ResponseModel response = new ResponseModel();

            try
            {
                var cacheData = _memoryCachingService.GetList <EmployeeWorkingStatusModel>(CacheKey);

                if (cacheData != null)
                {
                    response.Result = cacheData;
                }
                else
                {
                    var query = from m in _context.EmployeeWorkingStatusRepository.Query()
                                where m.IsActive && !m.Deleted
                                orderby m.Precedence ascending
                                select new EmployeeWorkingStatusModel
                    {
                        Id   = m.Id,
                        Name = m.Name
                    };

                    var list = await query.ToListAsync();

                    _memoryCachingService.Set <EmployeeWorkingStatusModel>(list, CacheKey, 30, 0, 0);

                    response.Result = list;
                }
            }
            catch (Exception ex)
            {
                response.ResponseStatus = Core.CommonModel.Enums.ResponseStatus.GetDropDownError;
                _logger.LogError(ex.Message, ex);
            }
            return(response);
        }