Пример #1
0
        public async Task Create(Project project)
        {
            if (project is null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            await _projectRepository.Create(project.Adapt <ProjectEntity>());
        }
Пример #2
0
        public async Task Create(Project project, string userIdentityLogin)
        {
            if (project is null)
            {
                throw new ArgumentNullException(nameof(project));
            }
            if (string.IsNullOrEmpty(userIdentityLogin))
            {
                throw new ArgumentException("message", nameof(userIdentityLogin));
            }

            await _projectRepository.Create(project.Adapt <ProjectEntity>(), userIdentityLogin);
        }
Пример #3
0
        public async Task <ProjectResponse> Handle(CreateProjectRequest request)
        {
            var manager = await _userRepository.ReadById(request.ManagerUserId);

            if (manager == default)
            {
                throw new ArgumentNullException(nameof(manager));
            }

            var project = new Project(request.Name, manager);

            project.UpdateDescriptionTo(request.Description);

            _projectRepository.Create(project);
            await _projectRepository.PersistChanges();

            return(project.Adapt <ProjectResponse>());
        }