예제 #1
0
        public async Task AddMembers(IEnumerable <MemberInput> input)
        {
            var     memberInputs = input as IList <MemberInput> ?? input.ToList();
            Project project      = null;

            if (memberInputs.ToList().Any())
            {
                project = _projectManager.GetProject(memberInputs.First().ProjectId);
            }
            foreach (var memberInput in memberInputs)
            {
                var projectMember = ProjectMember.CreateMember(memberInput.UserId, memberInput.ProjectId, memberInput.Leader);
                _membersManager.AddMember(projectMember);

                await _projectNotificationSubscriptionService.RegisterToGeneralNotifications(project, memberInput.UserId);

                if (memberInput.Leader)
                {
                    await _projectNotificationPublisherService.NotifyAddedAsLeader(project, memberInput.UserId);
                }
                else
                {
                    await _projectNotificationPublisherService.NotifyAddedMember(project, memberInput.UserId);
                }
            }
        }
예제 #2
0
        public async Task <MemberDto> AddMember(MemberInput input)
        {
            var projectMember = ProjectMember.CreateMember(input.UserId, input.ProjectId, input.Leader);

            _membersManager.AddMember(projectMember);
            var memberAdded = _membersManager.GetMember(input.ProjectId, input.UserId);
            var project     = _projectManager.GetProject(input.ProjectId);
            await _projectNotificationSubscriptionService.RegisterToGeneralNotifications(project, input.UserId);

            if (projectMember.Leader)
            {
                await _projectNotificationPublisherService.NotifyAddedAsLeader(project, input.UserId);
            }

            return(memberAdded.MapTo <MemberDto>());
        }