public async Task <IActionResult> AddNewVersion([FromRoute] int id, [FromBody] TemplateVersionInput templateInput)
        {
            LogBeginOfRequest();
            if (!ModelState.IsValid)
            {
                LogEndOfRequest("Failed Bad Request", 400);
                return(BadRequest(ModelState));
            }

            var command = new AddTemplateVersionCommand(id, templateInput);
            await templateService.AddTemplateVersionCommand.HandleAsync(command);

            LogEndOfRequest("Success", 204);
            return(NoContent());
        }
        public async Task <IActionResult> PostTemplate([FromBody] TemplateVersionInput templateInput)
        {
            LogBeginOfRequest();
            try
            {
                if (!ModelState.IsValid)
                {
                    LogEndOfRequest("Failed Bad Request", 400);
                    return(BadRequest(ModelState));
                }

                var command = new AddTemplateCommand(templateInput);
                await templateService.AddTemplateCommand.HandleAsync(command);

                LogEndOfRequest("Success", 200);
                return(Ok());
            }
            catch (Exception)
            {
                LogEndOfRequest($"Failed user with id {templateInput.AuthorId} not found", 404);
                return(NotFound());
            }
        }
Example #3
0
 public AddTemplateVersionCommand(int id, TemplateVersionInput templateVersionInput)
 {
     TemplateId = id;
     NewTemplateVersionInput = templateVersionInput;
 }
Example #4
0
 public AddTemplateCommand(TemplateVersionInput templateVersionInput)
 {
     NewTemplateVersionInput = templateVersionInput;
 }