Ejemplo n.º 1
0
        public async Task <IActionResult> CreateNewTemplate([FromBody] TemplateCreationDto dto)
        {
            try
            {
                dto.AuthorID = ObjectId.Parse(tokenService.GetTokenClaim(requestService.GetToken(Request), "ID"));
                var createdTemplate = await templateService.CreateNewTemplate(dto).ConfigureAwait(false);

                return(new OkJson <TemplateDto>(createdTemplate));
            }
            catch (FormatException)
            {
                return(new BadSentRequest <string>("userID is incorrect format"));
            }
            catch (ArgumentException ex)
            {
                return(new BadSentRequest <string>(ex.Message));
            }
            catch (DatabaseException ex)
            {
                return(new InternalServerError(ex.Message));
            }
            catch (Exception ex)
            {
                exceptionLogger.Log(new ApplicationError(ex), LogLevel.Error, logConfiguration);
                return(new InternalServerError());
            }
        }