public async Task <IActionResult> Create(HttpProfile profile) { try { await _context.CreateHttpProfile(profile, await _userManager.GetUserAsync(HttpContext.User)); return(RedirectToAction("Index", "Listener")); } catch (Exception e) when(e is ControllerNotFoundException || e is ControllerBadRequestException || e is ControllerUnauthorizedException) { return(RedirectToAction("Index", "Listener")); } }
public async Task <ActionResult <HttpProfile> > CreateHttpProfile([FromBody] HttpProfile profile) { try { HttpProfile createdProfile = await _context.CreateHttpProfile(profile, await _userManager.GetUserAsync(HttpContext.User)); return(CreatedAtRoute(nameof(GetHttpProfile), new { id = createdProfile.Id }, createdProfile)); } catch (ControllerNotFoundException e) { return(NotFound(e.Message)); } catch (ControllerBadRequestException e) { return(BadRequest(e.Message)); } catch (ControllerUnauthorizedException) { return(new UnauthorizedResult()); } }