Exemplo n.º 1
0
        public async Task <IActionResult> Create(ImplantTemplate template)
        {
            try
            {
                await _context.CreateImplantTemplate(template);

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception e) when(e is ControllerNotFoundException || e is ControllerBadRequestException || e is ControllerUnauthorizedException)
            {
                return(RedirectToAction(nameof(Index)));
            }
        }
        public async Task <ActionResult <ImplantTemplate> > CreateImplantTemplate([FromBody] ImplantTemplate template)
        {
            try
            {
                ImplantTemplate createdTemplate = await _context.CreateImplantTemplate(template);

                return(CreatedAtRoute(nameof(GetImplantTemplate), new { id = createdTemplate.Id }, createdTemplate));
            }
            catch (ControllerNotFoundException e)
            {
                return(NotFound(e.Message));
            }
            catch (ControllerBadRequestException e)
            {
                return(BadRequest(e.Message));
            }
        }