Exemplo n.º 1
0
        public async Task <IActionResult> Create(EmbeddedResource resource)
        {
            try
            {
                EmbeddedResource createdResource = await _context.CreateEmbeddedResource(resource);

                return(RedirectToAction(nameof(Edit), new { Id = createdResource.Id }));
            }
            catch (Exception e) when(e is ControllerNotFoundException || e is ControllerBadRequestException || e is ControllerUnauthorizedException)
            {
                return(View(new EmbeddedResource()));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult <EmbeddedResource> > CreateEmbeddedResource([FromBody] EmbeddedResource resource)
        {
            try
            {
                EmbeddedResource createdResource = await _context.CreateEmbeddedResource(resource);

                return(CreatedAtRoute(nameof(GetEmbeddedResource), new { id = createdResource.Id }, createdResource));
            }
            catch (ControllerNotFoundException e)
            {
                return(NotFound(e.Message));
            }
            catch (ControllerBadRequestException e)
            {
                return(BadRequest(e.Message));
            }
            catch (ControllerUnauthorizedException)
            {
                return(new UnauthorizedResult());
            }
        }