示例#1
0
        public async Task <PaginatedListResult <CompanyLicence> > Search(CompanyLicencesRequestViewModel viewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            var query = BaseQuery();

            query = SearchFilter(query, viewModel);
            query = SearchSort(query, viewModel);

            return(await query.ToPaginatedListResultAsync(viewModel));
        }
        public async Task <ServiceResult <PaginatedListResult <CompanyLicencesResponseViewModel> > > Search(CompanyLicencesRequestViewModel viewModel)
        {
            var paginatedListWithModel = await _repository.Search(viewModel);

            List <CompanyLicencesResponseViewModel> Mapping(List <CompanyLicence> list)
            {
                return(list?
                       .Select(model => new CompanyLicencesResponseViewModel
                {
                    Id = model.Id,
                    ExpiresOn = model.ValidToDate,
                    LicenceKey = model.LicenceKey,
                    LincenceUpdatingDateTime = model.ValidToDate,
                    Version = model.Version
                })
                       .ToList());
            }

            var paginatedListWithViewModel = paginatedListWithModel.Copy(Mapping);

            return(ServiceResultFactory.Success(paginatedListWithViewModel));
        }
 public async Task <ServiceResult <PaginatedListResult <DistributedLicencesResponseViewModel> > > DistributedLicences(CompanyLicencesRequestViewModel viewModel)
 {
     throw new System.NotImplementedException();
 }
示例#4
0
 public async Task <IActionResult> DistributedLicences([FromQuery] CompanyLicencesRequestViewModel viewModel)
 => await HandleResultAsync(() => _service.DistributedLicences(viewModel));
示例#5
0
 public async Task <IActionResult> SearchByCompany([FromRoute] int id, [FromQuery] CompanyLicencesRequestViewModel viewModel)
 => await HandleResultAsync(() => _service.Search(viewModel));     // TODO filter by id
示例#6
0
 public async Task <IActionResult> Search([FromQuery] CompanyLicencesRequestViewModel viewModel)
 => await HandleResultAsync(() => _service.Search(viewModel));
示例#7
0
        protected IQueryable <CompanyLicence> SearchSort(IQueryable <CompanyLicence> query, CompanyLicencesRequestViewModel viewModel)
        {
            string sortName = viewModel.SortName?.ToUpper();

            if (sortName == CompanyLicencesRequestViewModel.OrderFields.LicenceKey)
            {
                query = query.OrderUsingSearchOptions(viewModel, x => x.LicenceKey);
            }
            else if (sortName == CompanyLicencesRequestViewModel.OrderFields.ValidToDate)
            {
                query = query.OrderUsingSearchOptions(viewModel, x => x.ValidToDate);
            }
            else if (sortName == CompanyLicencesRequestViewModel.OrderFields.LastCheckedDate)
            {
                query = query.OrderUsingSearchOptions(viewModel, x => x.LastCheckedDate);
            }
            else if (sortName == CompanyLicencesRequestViewModel.OrderFields.Version)
            {
                query = query.OrderUsingSearchOptions(viewModel, x => x.Version);
            }
            else
            {
                query = query.OrderBy(x => x.Id);
            }
            return(query);
        }
示例#8
0
 protected IQueryable <CompanyLicence> SearchFilter(IQueryable <CompanyLicence> query, CompanyLicencesRequestViewModel viewModel)
 {
     return(query);
 }