Class UserExtensions
- Namespace
- Dynamicweb.Frontend
- Assembly
- Dynamicweb.dll
Extension helpers for mapping User entities to frontend view models.
public static class UserExtensions
- Inheritance
-
UserExtensions
- Inherited Members
Remarks
This static class contains extension methods intended for use in frontend rendering scenarios.
Methods are side-effect free and delegate model construction to ContentViewModelFactory to ensure
consistent mapping logic across the application.
Methods
GetUserViewModel(User)
Creates a UserViewModel for the specified User.
Validates the input and delegates construction to ContentViewModelFactory.
public static UserViewModel GetUserViewModel(this User user)
Parameters
userUserThe
Userinstance to map into aUserViewModel.
Returns
- UserViewModel
A
UserViewModelrepresenting the providedUser.
Examples
Example usage in a rendering component:
var userViewModel = currentUser.GetUserViewModel();
// Pass the view model to the view for rendering
Exceptions
- ArgumentNullException
Thrown when
userisnull.