Exemplo n.º 1
0
        public async Task <TResponse <PageResult <CountryModel> > > GetPaging(int userId,
                                                                              GetCountryPageModel request,
                                                                              int permissionId)
        {
            try
            {
                var checkValid = await _userService.CheckPermission(userId,
                                                                    permissionId);

                if (checkValid.IsSuccess)
                {
                    var countries = await _countryCacheService.GetList();

                    if (countries != null)
                    {
                        var result = countries.Where(c => c.Name.IsContainsEx(request.Name))
                                     .OrderByEx(request.ColumnOrder,
                                                request.SortDir)
                                     .Select(c => new CountryModel(c));
                        return(await Ok(new PageResult <CountryModel>(request.Page,
                                                                      request.PageSize,
                                                                      result.Count(),
                                                                      result.ToPageResult(request))));
                    }

                    return(await Ok(new PageResult <CountryModel>(request.Page,
                                                                  request.PageSize,
                                                                  0,
                                                                  new List <CountryModel>())));
                }

                return(await Fail <PageResult <CountryModel> >(checkValid.Message));
            }
            catch (Exception exception)
            {
                return(await Fail <PageResult <CountryModel> >(exception));
            }
        }
Exemplo n.º 2
0
        private async Task LoadCountries(bool firstLoad)
        {
            var countries = await _countryCacheService.GetList(firstLoad);

            _logger.Info($"Load {countries.Count} countries from redis cache");
        }