示例#1
0
        public async Task <ActionResult <Profile> > CreateProfile([FromBody] Profile profile)
        {
            try
            {
                Profile createdProfile = await _service.CreateProfile(profile, await _userManager.GetUserAsync(HttpContext.User));

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