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

                if (checkValid.IsSuccess)
                {
                    var manufacturers = await _manufacturerCacheService.GetList();

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

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

                return(await Fail <PageResult <ManufacturerModel> >(checkValid.Message));
            }
            catch (Exception exception)
            {
                return(await Fail <PageResult <ManufacturerModel> >(exception));
            }
        }
Exemplo n.º 2
0
        private async Task LoadManufacturers(bool firstLoad)
        {
            var manufacturers = await _manufacturerCacheService.GetList(firstLoad);

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