public void CheckUpdateAllowed()
        {
            RuleFor(x => x)
            .Must(newSolnEx =>
            {
                var oldSolnEx = _datastore.BySolution(newSolnEx.Solution.Id);
                return(MustBePendingToChangeClaimedCapability(oldSolnEx, newSolnEx));
            })
            .WithMessage("Must Be Pending To Change Claimed Capability");

            RuleFor(x => x)
            .Must(newSolnEx =>
            {
                var oldSolnEx = _datastore.BySolution(newSolnEx.Solution.Id);
                return(MustBePendingToChangeClaimedStandard(oldSolnEx, newSolnEx));
            })
            .WithMessage("Must Be Pending To Change Claimed Standard");

            RuleFor(x => x)
            .Must(newSolnEx =>
            {
                var oldSolnEx = _datastore.BySolution(newSolnEx.Solution.Id);
                return(MustBePendingToChangeClaimedCapabilityEvidence(oldSolnEx, newSolnEx));
            })
            .WithMessage("Must Be Pending To Change Claimed Capability Evidence");

            RuleFor(x => x)
            .Must(newSolnEx =>
            {
                var oldSolnEx = _datastore.BySolution(newSolnEx.Solution.Id);
                return(MustBePendingToChangeClaimedStandardEvidence(oldSolnEx, newSolnEx));
            })
            .WithMessage("Must Be Pending To Change Claimed Standard Evidence");
        }
        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;
            }));
        }
예제 #4
0
        public IActionResult BySolution([FromRoute][Required] string solutionId)
        {
            var solutionClaims = _datastore.BySolution(solutionId);

            return(solutionClaims?.Solution != null ? (IActionResult) new OkObjectResult(solutionClaims) : new NotFoundResult());
        }
 public SolutionEx BySolution(string solutionId)
 {
     return(_filter.Filter(new[] { _datastore.BySolution(solutionId) }).SingleOrDefault());
 }