コード例 #1
0
        public async Task <IResult> CreateProjectAsync(ProjectCreateWriteModel project, string creatorId)
        {
            using (var unitOfWork = _unitOfWorkFactory.Get(false))
            {
                var projectDomainService = _projectDomainServiceFactory.Get(unitOfWork);

                projectDomainService.CreateProject(project, creatorId);

                return(await CreateResultAsync(unitOfWork));
            }
        }
コード例 #2
0
        public void CreateProject(ProjectCreateWriteModel project, string creatorId)
        {
            var projectEntity = new ProjectEntity
            {
                Name        = project.Name,
                Description = project.Description,
                MemberToken = project.MemberToken,
                Members     = project.Members.Select(m => new UserProjectEntity
                {
                    UserId = m.Id
                }).ToList()
            };

            projectEntity.Members.Add(new UserProjectEntity {
                UserId = creatorId, IsActivated = true, IsDeafult = true
            });

            WriteRepository.Add(projectEntity);
        }
コード例 #3
0
ファイル: ProjectController.cs プロジェクト: GooRiOn/Aurora
        public async Task <IResult> CreateProjectAsync([FromBody] ProjectCreateWriteModel project)
        {
            if (!ModelState.IsValid)
            {
                var errors = ModelState.Values.SelectMany(v => v.Errors).Select(v => v.ErrorMessage).ToArray();
                return(CreateResult(ResultStateEnum.Failed, errors));
            }

            project.MemberToken = Guid.NewGuid();

            var userId = GetUserId();
            var result = await _projectDomainServiceProxy.CreateProjectAsync(project, userId);

            if (result.State == ResultStateEnum.Failed)
            {
                return(result);
            }

            var tasks = project.Members.Select(member => _emailService.SendProjectJoinEmailAsync(project.Name, project.MemberToken, member.Email)).ToArray();

            Task.WaitAll(tasks);

            return(result);
        }