Exemplo n.º 1
0
        public async Task <IActionResult> Create([FromBody] CreateCollectionRequest request)
        {
            try
            {
                var userKey = _contextAccessor.UserKeyFromContext();

                var newCollection = await _hiarcDatabase.CreateCollection(request, userKey);

                var uri = $"{_hiarcSettings.BaseUri}/collections/{newCollection.Key}";
                return(Created(uri, newCollection));
            }
            catch (InvalidOperationException ex)
            {
                _logger.LogError(ex.Message);
                return(StatusCode(StatusCodes.Status403Forbidden));
            }
            catch (Exception ex)
            {
                return(BuildErrorResponse(ex, _logger));
            }
        }