Example #1
0
        public async Task <IActionResult> ChangeName([FromBody] ChangeNameRequest request)
        {
            try
            {
                var thisUserId = ClaimsExtractor.GetUserIdClaim(User.Claims);

                await mUsersService.ChangeName(request.newName, thisUserId);

                return(Ok(new ResponseApiModel <bool>
                {
                    IsSuccessfull = true
                }));
            }
            catch (InvalidDataException ex)
            {
                return(BadRequest(new ResponseApiModel <bool>
                {
                    IsSuccessfull = false,
                    ErrorMessage = ex.Message
                }));
            }
            catch (KeyNotFoundException ex)
            {
                return(NotFound(new ResponseApiModel <bool>
                {
                    IsSuccessfull = false,
                    ErrorMessage = ex.Message
                }));
            }
            catch (Exception)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, new ResponseApiModel <bool>
                {
                    IsSuccessfull = false
                }));
            }
        }