Пример #1
0
        private async Task <Project> GetOrCreateProjectManagerAndAddProject(Guid userIdentifier, NewProject newProjectData)
        {
            var exists = await _projectMangerRepository.GetByUserIdentifierAsync(userIdentifier);

            Project project;

            if (exists == null)
            {
                var projectManager = new ProjectManager(userIdentifier);
                project = projectManager.AddProject(newProjectData.Title, newProjectData.StartDate, newProjectData.FinishDate);
                _projectMangerRepository.Add(projectManager);
                return(project);
            }

            project = exists.AddProject(newProjectData.Title, newProjectData.StartDate, newProjectData.FinishDate);
            _projectMangerRepository.Update(exists);
            return(project);
        }