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); }
public void NewProjectMap() { PortfolioMapper.Configure(); var newProject = new Project() { Reservation = new ProjectReservation() { ProjectId = "TEST123" } }; var model = ProjectModelFactory.GetProjectEditModel(newProject); Assert.IsNotNull(model); var minYear = DateTime.Now.Year - PortfolioSettings.ProjectDateMinYearOffset; var maxYear = DateTime.Now.Year + PortfolioSettings.ProjectDateMaxYearOffset; Assert.AreEqual(minYear, model.MinProjectYear); Assert.AreEqual(maxYear, model.MaxProjectYear); }