public async Task <IActionResult> CreateCatalog([FromHeader(Name = "Authorization")] string authorization, [FromBody] CatalogDto catalogDto) { if (!_userValidationService.CheckAuthorizationToken(authorization)) { return(Unauthorized()); } if (!(await _userValidationService.ValidateContentManager(authorization.Split(" ")[1]))) { return(Unauthorized()); } var userRef = await _userValidationService.GetUserRef(authorization.Split(" ")[1]); _logger.logInformation(userRef, LoggingEvents.PostItem, "Creating By Dto: {0}", catalogDto.Reference); ValidationOutput validationOutput = _catalogService.Register(catalogDto); if (validationOutput.HasErrors()) { if (validationOutput is ValidationOutputBadRequest) { _logger.logCritical(userRef, LoggingEvents.PostBadRequest, "Creating Catalog Failed: {0}", ((ValidationOutputBadRequest)validationOutput).ToString()); return(BadRequest(validationOutput.FoundErrors)); } if (validationOutput is ValidationOutputNotFound) { _logger.logCritical(userRef, LoggingEvents.PostNotFound, "Creating Catalog Failed: {0}", ((ValidationOutputNotFound)validationOutput).ToString()); return(NotFound(validationOutput.FoundErrors)); } _logger.logCritical(userRef, LoggingEvents.PostInternalError, "Type of validation output not recognized. Please contact your software provider."); return(BadRequest("Type of validation output not recognized. Please contact your software provider.")); } else { CatalogDto newCatalogDto = (CatalogDto)validationOutput.DesiredReturn; _logger.logInformation(userRef, LoggingEvents.PostOk, "Creating Catalog Succeeded: {0}", newCatalogDto.ToString()); return(CreatedAtRoute("GetCatalog", new { reference = newCatalogDto.Reference }, newCatalogDto)); } }