public IActionResult Get() { UpdateUserNameViewModel model = new UpdateUserNameViewModel(); var userId = _caller.Claims.Single(c => c.Type == "id"); var OnlineUser = _userManager.FindByIdAsync(userId.Value).Result; model.UserName = OnlineUser.UserName; model.Id = OnlineUser.Id; return(new OkObjectResult(model)); }
public IActionResult Put(string id, [FromBody] UpdateUserNameViewModel model) { if (model == null) { return(null); } var admin = _userManager.FindByIdAsync(id).Result; if (admin == null) { return(NotFound()); } admin.UserName = model.UserName; var result = _userManager.UpdateAsync(admin).Result; if (!result.Succeeded) { return(BadRequest()); } return(Ok()); }