Update User

Exercise - UpdateUserAsync


Exercise: Add UpdateUserAsync

You're doing great!

In the Conduit.Api Project, modify the UserController (again, notice the singular "User")

Add the following method
  • Name: UpdateUserAsync
  • Return Type: IActionResult
  • Parameters: ServiceRequest<UpdateUser>
Add the following Attributes to the method
  • HttpPut
  • Authorize
Add the following code to the body of the method
User user = await AccountRepo.UpdateLoggedInUser(req.User);
return Ok(new { user });

Resolve any namespace errors you're seeing

Implement Exception Handling
  • Wrap the code in the body of the method with a try…catch block
  • Catch both:
    • DuplicateEmailException
    • DuplicateUserNameException

Hint: Review the code in the GetCurentUserAsync method


I finished! On to the next chapter