public IEnumerable <SolutionEx> ByCapabilities(IEnumerable <string> capIds) { var capIdsQuoted = capIds.Select(x => $"'{x}'"); var capsSet = string.Join(",", capIdsQuoted); _logger.LogInformation($"{capsSet}"); return(GetInternal(() => { // get all Frameworks var allFrameworks = _frameworkDatastore.GetAll(); // get all Solutions via frameworks var allSolns = allFrameworks .SelectMany(fw => _solutionDatastore.ByFramework(fw.Id)); // get all unique Solutions with at least all specified Capability var allSolnsCapsIds = allSolns .Where(soln => _claimedCapabilityDatastore .BySolution(soln.Id) .Select(cc => cc.CapabilityId) .Intersect(capIds) .Count() >= capIds.Count()) .Select(soln => soln.Id); var retval = allSolnsCapsIds.Select(solnId => _solutionsExDatastore.BySolution(solnId)); return retval; })); }
public IEnumerable <SearchResult> ByKeyword(string keyword) { _logger.LogInformation($"{keyword}"); return(_policy.Execute(() => { // get all Frameworks var allFrameworks = _frameworkDatastore.GetAll(); // get all Solutions via frameworks var allSolns = allFrameworks .SelectMany(fw => _solutionDatastore.ByFramework(fw.Id)); // get all Capabilities via frameworks var allCapsFrameworks = allFrameworks .SelectMany(fw => _capabilityDatastore.ByFramework(fw.Id)); // get all Capabilities with keyword var allCapsKeywordIds = allCapsFrameworks .Where(cap => cap.Name.ToLowerInvariant().Contains(keyword.ToLowerInvariant()) || cap.Description.ToLowerInvariant().Contains(keyword.ToLowerInvariant())) .Select(cap => cap.Id); // get all unique Solutions with at least one ClaimedCapability with keyword var allSolnsCapsKeyword = allSolns .Where(soln => _claimedCapabilityDatastore .BySolution(soln.Id) .Select(cc => cc.CapabilityId) .Intersect(allCapsKeywordIds) .Any()) .Distinct(); var searchResults = allSolnsCapsKeyword.Select(soln => new SearchResult { SolutionEx = _solutionExDatastore.BySolution(soln.Id), Distance = _claimedCapabilityDatastore.BySolution(soln.Id).Count() - allCapsKeywordIds.Count() }); return searchResults; })); }
public virtual IActionResult ApiSolutionsByFrameworkByFrameworkIdGet([FromRoute][Required] string frameworkId, [FromQuery] int?pageIndex, [FromQuery] int?pageSize) { IEnumerable <Solution> solutions; int totalPages; try { solutions = _datastore.ByFramework(frameworkId); solutions = _datastore.GetPagingValues(pageIndex, pageSize, solutions, out totalPages); } catch (Crm.CrmApiException ex) { return(StatusCode((int)ex.HttpStatus, ex.Message)); } return(new ObjectResult(new PaginatedListSolutions() { Items = solutions.ToList(), TotalPages = totalPages, PageIndex = pageIndex ?? Paging.DefaultIndex, PageSize = pageSize ?? Paging.DefaultPageSize })); }
public IEnumerable <Solutions> ByFramework(string frameworkId) { return(_filter.Filter(_datastore.ByFramework(frameworkId))); }