public GroupResponse Create(string name, string description) { var group = new Models.Group { Id = Guid.NewGuid(), Name = name, Description = description }; var user = _authorizedUserHelper.GetAuthorizedUser(); var groupUser = new GroupUser(user, group, Role.Admin); var documentGroupUser = new Documents.GroupUser(user.Id, group.Id); _groupUserRepository.Add(groupUser); _groupUserStore.AddToBus(documentGroupUser); _groupEventService.AddGroupCreatedEvent(group, _user); _groupEventService.AddUserAddedToGroupEvent(group, _user, _user); _mailService.SendMail( user.Email, "CallGate - New group created successfully", $"Congratz! You created a new group '{name}'." ); return(_mapper.Map <GroupResponse>(group)); }
public void AddUserToGroup(string username, Role role, Guid groupId) { var user = _userRepository.GetUserByUsername(username); var group = _groupRepository.Get(groupId); var groupUser = new GroupUser(user, group, role); var documentGroupUser = new Documents.GroupUser(user.Id, group.Id); _groupUserRepository.Add(groupUser); _groupUserStore.AddToBus(documentGroupUser); _groupEventService.AddUserAddedToGroupEvent(group, _authorizedUser, user); _mailService.SendMail( user.Email, $"CallGate - Welcome in the group '{group.Name}'", $"Group member '{_authorizedUser.Username}' added you to the group '{group.Name}'. Welcome!" ); }