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

                if (checkValid.IsSuccess)
                {
                    var crmStatuses = await _crmStatusCacheService.GetList();

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

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

                return(await Fail <PageResult <CrmStatusModel> >(checkValid.Message));
            }
            catch (Exception exception)
            {
                return(await Fail <PageResult <CrmStatusModel> >(exception));
            }
        }
Esempio n. 2
0
        private async Task LoadCrmStatuses(bool firstLoad)
        {
            var crmStatuses = await _crmStatusCacheService.GetList(firstLoad);

            _logger.Info($"Load {crmStatuses.Count} crm statuses from redis cache");
        }