Exemplo n.º 1
0
        public ManagersResponse GetManagers(int page, int pageSize, ManagerFilters filters)
        {
            var query = _dbContext.Managers.AsQueryable().AsNoTracking();

            if (filters.IsTimeFilterEnabled.HasValue && filters.IsTimeFilterEnabled.Value)
            {
                var managersResponse = from managers in _dbContext.Managers
                                       join history in _dbContext.ManagersWorkingHistory
                                       on managers.Id equals history.ManagerId
                                       orderby history.StartedWorkingAt
                                       select managers;

                query = managersResponse;
            }

            if (filters.ShopId.HasValue && filters.ShopId.Value != 0)
            {
                query = query.Where(manager => manager.CurrentShopId == filters.ShopId);
            }

            if (filters.Status is not null)
            {
                query = query.Where(manager => manager.Status.StartsWith(filters.Status));
            }

            return(new ManagersResponse
            {
                Managers = query.Skip(page * pageSize).Take(pageSize).ToList(),
                TotalManagers = query.Count()
            });
        }
        public AllManagersResponseViewModel GetManagers(int currentPage, int pageSize, bool?isTimeFilterEnabled, int?shopId, string status)
        {
            var managerFilters = new ManagerFilters
            {
                IsTimeFilterEnabled = isTimeFilterEnabled,
                ShopId = shopId,
                Status = status
            };

            var allManagers = _managerService.GetManagers(currentPage - 1, pageSize, managerFilters);

            return(_mapper.Map <AllManagersResponseViewModel>(allManagers));
        }
        public AllManagersResponseModel GetManagers(int page, int pageSize, ManagerFilters filters)
        {
            var allManagers = _managerRepository.GetManagers(page, pageSize, filters);

            return(_mapper.Map <AllManagersResponseModel>(allManagers));
        }