Beispiel #1
0
        public async Task <StatusCodes> CreateItemAsync(GroupModel modelObject, string requestId = "")
        {
            _logger.LogInformation($"RequestId: {requestId} - Groups_CreateItemAsync called.");

            Guard.Against.Null(modelObject, nameof(modelObject), requestId);
            Guard.Against.NullOrEmpty(modelObject.GroupName, nameof(modelObject.GroupName), requestId);
            try
            {
                var entityObject = MapToEntity(modelObject);

                var result = await _groupsRepository.CreateItemAsync(entityObject, requestId);

                Guard.Against.NotStatus201Created(result, "Groups_CreateItemAsync", requestId);

                _logger.LogInformation($"Group created: {modelObject}");

                _groupsRepository.CleanCache();
                _logger.LogInformation("Cleaned group cache");

                userProfileRepository.CleanCache();
                _logger.LogInformation("Cleaned user profile cache");

                return(result);
            }
            catch (Exception ex)
            {
                _logger.LogError($"RequestId: {requestId} - Groups_CreateItemAsync Service Exception: {ex}");
                throw new ResponseException($"RequestId: {requestId} - Groups_CreateItemAsync Service Exception: {ex}");
            }
        }