Beispiel #1
0
        public PagedResultDto <CommonUserForProfileDto> GetCustomersOfChannelAgency(CustomerGetAllInput input)
        {
            User user  = GetCurrentUser();
            var  query = UserRespository.GetAll().WhereIf(input.Depth == 1, model => model.ChannelAgencyId == user.UserChannelAgencyId)
                         .WhereIf(input.ShouldBePotential, model => model.IsSpreader == false)
                         .WhereIf(input.Depth == 2, model => model.ParentUserId.HasValue && model.ParentUser.ParentUserId == InfrastructureSession.UserId.Value)
                         .WhereIf(input.Depth == 3, model => model.ParentUserId.HasValue && model.ParentUser.ParentUserId.HasValue && model.ParentUser.ParentUser.ParentUserId == InfrastructureSession.UserId.Value);
            var totalCount = query.Count();

            query = query.PageBy((input.PageIndex - 1) * input.PageSize, input.PageSize);

            var entities = query.ToList();

            return(new PagedResultDto <CommonUserForProfileDto>(
                       totalCount,
                       input.PageIndex,
                       input.PageSize,
                       entities.Select(model => ObjectMapper.MapTo <CommonUserForProfileDto>()).ToList()
                       ));
        }
Beispiel #2
0
        public PagedResultDto <CustomerDto> GetCustomers(CustomerGetAllInput input)
        {
            var query = Repository.GetAll().WhereIf(input.Depth == 1, model => model.ParentUserId == InfrastructureSession.UserId.Value)
                        .WhereIf(input.ShouldBePotential, model => model.IsSpreader == false)
                        .WhereIf(input.Depth == 2, model => model.ParentUserId.HasValue && model.ParentUser.ParentUserId == InfrastructureSession.UserId.Value)
                        .WhereIf(input.Depth == 3, model => model.ParentUserId.HasValue && model.ParentUser.ParentUserId.HasValue && model.ParentUser.ParentUser.ParentUserId == InfrastructureSession.UserId.Value);
            var totalCount = query.Count();

            query = ApplySorting(query, input);
            query = ApplyPaging(query, input);

            var entities = query.ToList();

            return(new PagedResultDto <CustomerDto>(
                       totalCount,
                       input.PageIndex,
                       input.PageSize,
                       entities.Select(MapToEntityDto).ToList()
                       ));
        }