public async Task <IActionResult> ChangeLastName([FromRoute] string username, [FromBody] ClientChangeLastNameRequest request) { if (string.IsNullOrEmpty(request.NewLastName)) { return(BadRequest("Request model is not correct")); } var userRole = HttpContext.User.Claims.FirstOrDefault(x => x.Type == "Role").Value.ToString(); var userNameFromJwt = HttpContext.User.Claims.FirstOrDefault(x => x.Type == "UserName").Value.ToString(); if (request.NewLastName.Length < 2) { return(BadRequest("Length should be more then 1 chars")); } if (userRole == "admin" || userNameFromJwt == username) { var changeResponse = await _clientDataService.ChangeLastNameAsync(username, request.NewLastName); if (!changeResponse.Success) { return(BadRequest(changeResponse.ErrorsMessages)); } return(Ok("Last name was successfully change")); } else { return(Forbid()); } }