Ejemplo n.º 1
0
        public async Task <StatusCodes> CreateItemAsync(RegionModel modelObject, string requestId = "")
        {
            _logger.LogInformation($"RequestId: {requestId} - Region_CreateItemAsync called.");

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

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

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

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