public async Task <GetProjectDTO <ProjectEditViewModel> > CreateNewProjectAsync(string portfolio)
        {
            var context = ServiceContext.PortfolioContext;
            var config  = await portfolioService.GetConfigAsync(portfolio);

            ServiceContext.AssertPermission(config.Portfolio);
            var reservation = await portfolioService.GetProjectReservationAsync(config);

            await context.SaveChangesAsync();

            var newProject = new Project()
            {
                Reservation = reservation
            };

            ProjectEditViewModel newProjectModel = ProjectModelFactory.GetProjectEditModel(newProject);

            var result = new GetProjectDTO <ProjectEditViewModel>()
            {
                Config  = PortfolioMapper.GetProjectLabelConfigModel(config, PortfolioFieldFlags.Create),
                Options = await portfolioService.GetNewProjectOptionsAsync(config),
                Project = newProjectModel
            };

            return(result);
        }
Esempio n. 2
0
        public async Task <GetProjectQueryDTO> FilterOptionsAsync([FromUri(Name = "portfolio")] string viewKey)
        {
            GetProjectQueryDTO result = null;

            using (var context = new PortfolioContext())
            {
                var config = await portfolioService.GetConfigAsync(viewKey);

                var customFields = portfolioService.GetCustomFilterLabels(config);

                result = new GetProjectQueryDTO()
                {
                    Config  = PortfolioMapper.GetProjectLabelConfigModel(config, PortfolioFieldFlags.FilterProject | PortfolioFieldFlags.FilterRequired, customLabels: customFields),
                    Options = await portfolioService.GetNewProjectOptionsAsync(config)
                };
            }
            return(result);
        }