public async Task <ProjectImportSuccessStatus> Import(MbeProject engProject, string userId) { var _projectDomain = ObjectLocator.DomainObjectFactory.ProjectDomain; var mbeProjectClient = ObjectLocator.ProjectImportAdapter; //mbeProjectClient. //var _projectImportAdapter = this.ObjectLocator.ProjectImportAdapter; var createdProject = await _projectDomain.ImportAsync(engProject, userId); var projectMSResult = new ProjectImportSuccessStatus(createdProject.MBEProjectId); if (createdProject != null) { // Set Progress project id in Engineering project (only a single Progress project is allowed per Engineering project) var isUpdateSuccessfull = await mbeProjectClient.SetManagementProjectId(createdProject.MBEProjectId, createdProject.Id); if (isUpdateSuccessfull) { var doorMSResult = await ObjectLocator.MbeDoorService.ImportDoors(createdProject.MBEProjectId, createdProject.Id); if (doorMSResult.IsSuccess) { projectMSResult.Project = createdProject; projectMSResult.IsSuccess = true; Task addProjectDocuments = ObjectLocator.DomainObjectFactory.ProjectDocumentDomain.ImportProjectDocuments(createdProject.MBEProjectId, createdProject.Id, this.ObjectLocator.ProjectDocumentImportAdapter); Task addFieldHeaders = _projectDomain.ImportFieldHeaders(createdProject.MBEProjectId, createdProject.Id, mbeProjectClient, userId); await Task.WhenAll(addProjectDocuments, addFieldHeaders); } else { await _projectDomain.DeleteProject(engProject.Id, userId); projectMSResult.IsSuccess = false; projectMSResult.Error = doorMSResult.Error; } } else { await _projectDomain.DeleteProject(engProject.Id, userId); projectMSResult.IsSuccess = false; //projectMSResult.Error = "Project creation failed. Please try again or consult the developers."; projectMSResult.Error = "Project creation failed. Please try again or consult the developers."; } } else { projectMSResult.IsSuccess = false; //projectMSResult.Error = "Project creation failed. Please try again or consult the developers."; projectMSResult.Error = "Project creation failed. Please try again or consult the developers."; } return(projectMSResult); }
public async Task <ProjectImportSuccessStatus> AddNewProject(Project project, string userId) { var proj = await _projectRepository.AddAsync(project); var result = new ProjectImportSuccessStatus(proj.MBEProjectId); result.IsSuccess = true; result.Project = proj; return(result); }
public async Task <ProjectImportSuccessStatus> CreateProjectsAsync(string userId, Project project) { ProjectImportSuccessStatus result = await domainObjectFactory.ProjectDomain.AddNewProject(project, userId); try { if (result.IsSuccess) { bool isActivationDeactivation = false; //to do uncomments //EmailService _emailService = new EmailService(); //_emailService.SendProjectNotificationMail(userId, project, isActivationDeactivation); } return(result); } catch (Exception e) { return(null); } }