Example #1
0
        public void Execute(CalculationContext context)
        {
            var helper = new FeaturesHelper();

            var random = new Random();

            var features = context.Project.Webshops.SelectMany(w => w.Features)
                           .Where(f => !f.Implemented)
                           .OrderByDescending(f => f.RemainingImplementationRequirements != f.Definition.ImplementationRequirements)
                           .ThenByDescending(f => f.Definition.Type == BusinessConstants.FeatureTypes.Webshop)
                           .ThenByDescending(f => f.Definition.Tag == "ERP")
                           .ThenBy(f => helper.GetParentFeatures(f.Definition.Id).Count)
                           .ThenBy(f => random.Next());

            context.FeaturesToImplement = features.ToList();
        }
        private bool IsFeaturesSelectionValid(IEnumerable <Guid> ids)
        {
            if (ids != null)
            {
                var featuresHelper = new FeaturesHelper();

                foreach (var featureId in ids)
                {
                    var parents = featuresHelper.GetParentFeatures(featureId);
                    if (parents.Any(parent => !ids.Contains(parent.Id)))
                    {
                        ModelState.AddModelError(nameof(ids), "Invalid selection");

                        return(false);
                    }
                }
            }

            return(true);
        }
Example #3
0
        private static List <Feature> GetSortedFeaturesForBot()
        {
            var list = IoC.Session.GetObject <List <Feature> >("BotFeatures");

            if (list == null)
            {
                var random = new Random();
                var helper = new FeaturesHelper();

                list = Framework.Features.Get()
                       .OrderByDescending(f => f.Type == BusinessConstants.FeatureTypes.Webshop)
                       .ThenByDescending(f => f.Tag == "ERP")
                       .ThenBy(f => helper.GetParentFeatures(f.Id).Count)
                       .ThenBy(f => random.Next()).ToList();
            }

            IoC.Session.SetObject("BotFeatures", list);

            return(list);
        }