Пример #1
0
        public void AddMember(GroupMemberViewModel viewModel)
        {
            string userRole = _groupMemberRepository.GetRole(viewModel.GroupId, viewModel.CurrentUserId);

            if (userRole.Equals(RoleNames.ROLE_OWNER) &&
                !_groupMemberRepository.IsInGroup(viewModel.GroupId, viewModel.UserId))
            {
                var entity = viewModel.ToEntity();
                entity.JoinedAt = DateTime.Now;

                _groupMemberRepository.AddUserToGroup(entity);
            }
            else
            {
                throw new ArgumentException("User is already in this group.");
            }
        }