Example #1
0
        public async Task <string> Remove(int currentUserId, int groupTypeId)
        {
            VerifyManagementPermission();

            int usingThisType = 0;

            try
            {
                usingThisType = await _groupInfoRepository.GetCountByTypeAsync(groupTypeId);
            }
            catch (Exception ex)
            {
                return($"Unable to remove group type - cannot tell if any group(s) are using it: {ex.Message}");
            }

            if (usingThisType > 0)
            {
                return($"Unable to remove group type - {usingThisType} group(s) currently have it selected.");
            }

            try
            {
                await _groupTypeRepository.RemoveSaveAsync(currentUserId, groupTypeId);

                return(null);
            }
            catch (Exception ex)
            {
                return($"Unable to remove group type: {ex.Message}");
            }
        }