Example #1
0
        public async Task <GroupInfo> UpdateGroupName(int currentUserId, GroupInfo groupInfo)
        {
            if (currentUserId != groupInfo.UserId)
            {
                // verify user has modify users permission
                if (!HasPermission(Permission.EditParticipants))
                {
                    int userId = GetClaimId(ClaimType.UserId);
                    _logger.LogError($"User {userId} doesn't have permission to update a group name.");
                    throw new GraException("Permission denied.");
                }
            }

            var currentGroup = await _groupInfoRepository.GetByUserIdAsync(groupInfo.UserId);

            currentGroup.Name      = groupInfo.Name;
            currentGroup.GroupType = null;
            currentGroup.User      = null;
            return(await _groupInfoRepository.UpdateSaveAsync(currentUserId, currentGroup));
        }