Beispiel #1
0
        public static async Task <MaturityModelAssessmentResult> ComputeAsync(Guid projectId)
        {
            var result   = new MaturityModelAssessmentResult();
            var mmResult = new MaturityModelAssessmentResult();

            var maturityRepo = UtilDomain.GetService <IMaturityModelRepository>();

            var project = await maturityRepo.GetProjectAsync(projectId);

            var chapterIds = project.ChaptersIds.ToArray();
            var chapters   = await maturityRepo.GetChaptersAsync(chapterIds);

            var camps = await maturityRepo.GetCampsByChapters(chapterIds);

            var maturityModels = await maturityRepo.GetAsync(camps.Where(c => c.CampLevel != null).SelectMany(c => c.CampLevel.Select(cl => cl.Key)).ToArray());

            foreach (var chapter in chapters)
            {
                var chapterResult = result.AddChapters(chapter);

                foreach (var camp in camps)
                {
                    var campResult = chapterResult.AddCamps(camp);

                    foreach (var mm in maturityModels.Where(m => camp.ContainsMaturity(m.MaturityModelId)))
                    {
                        campResult.Validade(mm, project);
                    }
                }
            }

            return(result);
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <PAMDatabaseSettings>(
                Configuration.GetSection(nameof(PAMDatabaseSettings)));

            services.AddSingleton <IPAMDatabaseSettings>(sp =>
                                                         sp.GetRequiredService <IOptions <PAMDatabaseSettings> >().Value);

            services.AddSingleton <IMongoDatabase>(sp =>
            {
                var settings = (IPAMDatabaseSettings)sp.GetService(typeof(IPAMDatabaseSettings));

                var client = new MongoClient(settings.ConnectionString);
                return(client.GetDatabase(settings.DatabaseName));
            });

            services.AddSingleton <ChapterApplication>();
            services.AddSingleton <PlatformApplication>();
            services.AddSingleton <ProjectApplication>();
            services.AddSingleton <MaturityModelApplication>();

            services.AddSingleton <IChapterRepository, ChapterRepository>();
            services.AddSingleton <IPlatformRepository, PlatformRepository>();
            services.AddSingleton <IProjectRepository, ProjectRepository>();
            services.AddSingleton <IMaturityModelRepository, MaturityModelRepository>();

            services.AddControllers();

            services.AddSwaggerGen();

            UtilDomain.SetService(services.BuildServiceProvider());
        }
        public async Task SetMaturityModel(Guid maturityModelId, int value)
        {
            var maturityDefined = MaturityModels.Value.FirstOrDefault(m => m.MaturityModelId == maturityModelId);

            var maturityRepo = UtilDomain.GetService <IMaturityModelRepository>();
            var maturity     = await maturityRepo.GetAsync(maturityModelId);

            if (maturity == null)
            {
                throw new DefineMaturityModelNotFoundException(maturityModelId, this);
            }

            if (!maturity.Options.Exists(o => o.Value == value))
            {
                throw new DefineOptionMaturityModelNotFoundException(this, maturity, value);
            }

            if (maturityDefined == null)
            {
                maturityDefined = await MaturityModelDefined.CreateAsync(this, maturity, value);

                MaturityModels.Value.Add(maturityDefined);
            }
            else
            {
                await maturityDefined.UpdateAsync(value);
            }
        }
        public async Task AlterAsync(String?name, String?description, int?order, Guid?chapterId)
        {
            if (name != null && name.Length > 0)
            {
                this.Name = name;
            }

            if (description != null && description.Length > 0)
            {
                this.Description = description;
            }

            if (order.HasValue)
            {
                this.Order = order.Value;
            }

            if (chapterId.HasValue)
            {
                await SetChapter(chapterId.Value);
            }

            var mmRepo = UtilDomain.GetService <IMaturityModelRepository>();
            await mmRepo.SaveCampAsync(this);
        }
        public async Task UpdateAsync(int value)
        {
            Value = value;

            var projectRepo = UtilDomain.GetService <IProjectRepository>();
            await projectRepo.UpdateMaturityModel(this);
        }
        private List <MaturityModelDefined> LoadMaturityModelDefined()
        {
            if (_maturityModels == null)
            {
                var projectRepo = UtilDomain.GetService <IProjectRepository>();
                _maturityModels = projectRepo.GetMaturityModel(this.ProjectId).Result;
            }

            return(_maturityModels);
        }
        private IList <ChapterDomain> LoadChapters()
        {
            if (_chapters == null)
            {
                var projectRepo = UtilDomain.GetService <IProjectRepository>();
                _chapters = projectRepo.GetChapters(ChaptersIds).Result;
            }

            return(_chapters);
        }
        private PlatformDomain LoadPlatform()
        {
            if (_platformDomain == null)
            {
                var platformRepo = UtilDomain.GetService <IPlatformRepository>();
                _platformDomain = platformRepo.Get(this.PlatformId).Result;
            }

            return(_platformDomain);
        }
        public async Task DefineMaturtyModelAsync(MaturityModelDomain mm, int level)
        {
            if (CampLevel == null)
            {
                CampLevel = new List <KeyValuePair <Guid, float> >();
            }

            CampLevel.Add(new KeyValuePair <Guid, float>(mm.MaturityModelId, level));

            var mmRepo = UtilDomain.GetService <IMaturityModelRepository>();
            await mmRepo.SaveCampAsync(this);
        }
        public static async Task <MaturityModelDefined> CreateAsync(ProjectDomain project, MaturityModelDomain maturity, int value)
        {
            var mm = new MaturityModelDefined {
                MaturityModelId = maturity.MaturityModelId,
                ProjectId       = project.ProjectId,
                Value           = value
            };

            var projectRepo = UtilDomain.GetService <IProjectRepository>();
            await projectRepo.AddMaturityModel(mm);

            return(mm);
        }
        public async Task AlterOptionAsync(MaturityModelAlterOptionRequest request)
        {
            var maturityRepo = UtilDomain.GetService <IMaturityModelRepository>();

            var mm = await maturityRepo.GetAsync(request.MaturityId);

            if (mm == null)
            {
                throw new MaturityModelNotFoundException(request.MaturityId);
            }

            await mm.AlterOptionAsync(request.value, request.Name, request.Level);
        }
        private async Task SetChapter(Guid chapterId)
        {
            var mmRepo = UtilDomain.GetService <IMaturityModelRepository>();

            var chapter = (await mmRepo.GetChaptersAsync(chapterId)).FirstOrDefault();

            if (chapter == null)
            {
                throw new ChapterMaturityModelNotFoundException(this, chapterId);
            }

            this.ChapterId = chapterId;
            this.Chapter   = chapter;
        }
Beispiel #13
0
        public static async Task <MaturityModelDomain> CreateAsync(string name, string description, int order)
        {
            var maturityRepo = UtilDomain.GetService <IMaturityModelRepository>();

            var mm = new MaturityModelDomain
            {
                MaturityModelId = Guid.NewGuid(),
                Name            = name,
                Description     = description,
                Order           = order
            };

            await maturityRepo.SaveAsync(mm);

            return(mm);
        }
        public async Task SetChaptersAsync(IList <Guid> chaptersId)
        {
            var projectRepo = UtilDomain.GetService <IProjectRepository>();
            var chapters    = await projectRepo.GetChapters(chaptersId);

            var chaptersNotFound = chaptersId.Where(ci => !chapters.Any(c => c.ChapterId == ci)).ToArray();

            if (chaptersNotFound.Length > 0)
            {
                throw new ChapterProjectNotFoundException(this, chaptersNotFound);
            }

            this.ChaptersIds = chaptersId;
            this._chapters   = chapters;

            await projectRepo.Save(this);
        }
        public static async Task <CampDomain> CreateAsync(string name, string description, int order, Guid chapterId)
        {
            var mmRepo = UtilDomain.GetService <IMaturityModelRepository>();

            var camp = new CampDomain
            {
                CampId      = Guid.NewGuid(),
                Name        = name,
                Description = description,
                Order       = order
            };

            await camp.SetChapter(chapterId);

            await mmRepo.SaveCampAsync(camp);

            return(camp);
        }
        public static async Task <ProjectDomain> CreateProjectAsync(Guid platformId, String name)
        {
            var platformRepo   = UtilDomain.GetService <IPlatformRepository>();
            var platformDomain = await platformRepo.Get(platformId);

            if (platformDomain == null)
            {
                throw new PlatformNotFoundException(platformId);
            }

            var p = new ProjectDomain {
                ProjectId       = Guid.NewGuid(),
                PlatformId      = platformId,
                Name            = name,
                _platformDomain = platformDomain
            };

            return(p);
        }
        public async Task DefineMaturityModelCampAsync(MaturityModelCampDefineRequest request)
        {
            var maturityRepo = UtilDomain.GetService <IMaturityModelRepository>();

            var camp = (await maturityModelRepo.GetCampsAsync(request.CampId)).FirstOrDefault();

            if (camp == null)
            {
                throw new CampNotFoundException(request.CampId);
            }

            var mm = await maturityModelRepo.GetAsync(request.MaturityModelId);

            if (mm == null)
            {
                throw new MaturityModelNotFoundException(request.MaturityModelId);
            }

            await camp.DefineMaturtyModelAsync(mm, request.Level);
        }
Beispiel #18
0
        public async Task <OptionsDomain> IncludeOptionAsync(string name, int value, int level)
        {
            if (this.Options == null)
            {
                this.Options = new List <OptionsDomain>();
            }

            if (this.Options.Exists(o => o.Value == value))
            {
                throw new OptionMaturityModelAlreadyExistsException(this, value);
            }

            var option = OptionsDomain.CreateOption(name, value, level);

            this.Options.Add(option);

            var maturityRepo = UtilDomain.GetService <IMaturityModelRepository>();
            await maturityRepo.SaveAsync(this);

            return(option);
        }
Beispiel #19
0
        public async Task AlterOptionAsync(int value, string name, int?level)
        {
            var option = this.Options.Where(o => o.Value == value).FirstOrDefault();

            if (option == null)
            {
                throw new OptionMaturityModelNotFoundException(this, value);
            }

            if (!string.IsNullOrEmpty(name))
            {
                option.SetName(name);
            }

            if (level.HasValue)
            {
                option.SetLevel(level.Value);
            }

            var maturityRepo = UtilDomain.GetService <IMaturityModelRepository>();
            await maturityRepo.SaveAsync(this);
        }
        public async Task Save()
        {
            var platformRepo = UtilDomain.GetService <IPlatformRepository>();

            await platformRepo.Save(this);
        }
 public async Task SaveAsync()
 {
     var projectRepo = UtilDomain.GetService <IProjectRepository>();
     await projectRepo.Save(this);
 }