public Task <FilterResultModel <SystemLookupViewModel> > Handle(GetSystemLookupListQuery request, CancellationToken cancellationToken)
        {
            var sortBy        = request.SortBy.Trim() != "" ? request.SortBy : "Type";
            var sortDirection = (request.SortDirection.ToUpper() == "DESCENDING") ? true : false;

            FilterResultModel <SystemLookupViewModel> result = new FilterResultModel <SystemLookupViewModel> ();
            var lookup = _database.SystemLookup
                         .Where(l => l.Type.ToLower() != "system_lookup")
                         .Select(SystemLookupViewModel.Projection)
                         .Select(DynamicQueryHelper.GenerateSelectedColumns <SystemLookupViewModel> (request.SelectedColumns))
                         .AsQueryable();

            if (request.Filter.Count() > 0)
            {
                lookup = lookup
                         .Where(DynamicQueryHelper
                                .BuildWhere <SystemLookupViewModel> (request.Filter)).AsQueryable();
            }

            result.Count = lookup.Count();

            result.Items = lookup.OrderBy(sortBy, sortDirection).Skip(request.PageNumber)
                           .Take(request.PageSize)
                           .ToList();

            return(Task.FromResult <FilterResultModel <SystemLookupViewModel> > (result));
        }
示例#2
0
        public async Task ReturnListOfSystemLookupViewModel()
        {
            // Arrange
            GetSystemLookupListQuery query = new GetSystemLookupListQuery();
            // Act
            var result = await handler.Handle(query, CancellationToken.None);

            // Assert
            Assert.IsType <FilterResultModel <SystemLookupViewModel> > (result);
            Assert.True(result.Items.Count() > 0);
        }
        public async Task <ActionResult <FilterResultModel <SystemLookupViewModel> > > GetSystemLookUpList([FromBody] GetSystemLookupListQuery query)
        {
            var result = await _Mediator.Send(query);

            return(Ok(result));
        }