public virtual IActionResult ApiCapabilitiesGet([FromQuery] int?pageIndex, [FromQuery] int?pageSize)
        {
            IEnumerable <Capability> capabilities;
            int totalPages;

            try
            {
                capabilities = _datastore.GetAll();
                capabilities = _datastore.GetPagingValues(pageIndex, pageSize, capabilities, out totalPages);
            }
            catch (Crm.CrmApiException ex)
            {
                return(StatusCode((int)ex.HttpStatus, ex.Message));
            }

            return(new ObjectResult(new PaginatedListCapabilities()
            {
                Items = capabilities.ToList(),
                PageSize = pageSize ?? Paging.DefaultPageSize,
                TotalPages = totalPages,
                PageIndex = pageIndex ?? Paging.DefaultIndex
            }));
        }
        public IQueryable <SolutionEx> SolutionExByKeyword(string keyword)
        {
            // get all Solutions via frameworks
            var allSolns = _frameworkDatastore.GetAll()
                           .SelectMany(fw => _solutionDatastore.ByFramework(fw.Id));

            // get all Solutions with keyword in name or description
            var allSolnsKeywordIds = allSolns
                                     .Where(soln =>
                                            soln.Name.ToLowerInvariant().Contains(keyword.ToLowerInvariant()) ||
                                            soln.Description.ToLowerInvariant().Contains(keyword.ToLowerInvariant()))
                                     .Select(soln => soln.Id);

            // get all Capabilities with keyword
            var allCapsKeywordIds = _capabilityDatastore.GetAll()
                                    .Where(cap =>
                                           cap.Name.ToLowerInvariant().Contains(keyword.ToLowerInvariant()) ||
                                           cap.Description.ToLowerInvariant().Contains(keyword.ToLowerInvariant()))
                                    .Select(cap => cap.Id);

            // get all Solutions with at least one ClaimedCapability with keyword
            var allSolnsClaimedCapsIds = allSolns
                                         .Where(soln => _claimedCapabilityDatastore
                                                .BySolution(soln.Id)
                                                .Select(cc => cc.CapabilityId)
                                                .Intersect(allCapsKeywordIds)
                                                .Any())
                                         .Select(soln => soln.Id)
                                         .Distinct();

            // unique set of Solutions with keyword in name/description or ClaimedCapability
            var uniqueSolnIds = allSolnsKeywordIds
                                .Union(allSolnsClaimedCapsIds)
                                .Distinct();

            return(uniqueSolnIds.Select(solnId => _solutionExDatastore.BySolution(solnId)));
        }
 public IQueryable <Capability> GetAll()
 {
     return(_datastore.GetAll());
 }