Class UserViewModelExtensions
- Namespace
- Dynamicweb.Frontend
- Assembly
- Dynamicweb.dll
public static class UserViewModelExtensions
- Inheritance
-
UserViewModelExtensions
- Inherited Members
Methods
GetBillingAddresses(UserViewModel)
Retrieves a collection of user addresses allowed for billing.
public static IEnumerable<AddressViewModel> GetBillingAddresses(this UserViewModel model)
Parameters
modelUserViewModelThe user view model.
Returns
- IEnumerable<AddressViewModel>
An enumerable collection of AddressViewModel.
GetChangeActiveStatusLink(UserViewModel, int)
Gets the change active status link for the specified user.
public static string? GetChangeActiveStatusLink(this UserViewModel model, int pageId)
Parameters
modelUserViewModelThe UserViewModel instance.
pageIdintThe page ID.
Returns
- string
The delete user link if the
modelis not null; otherwise, null.
GetCountrySpecificStreetAddress(UserViewModel)
Gets the country-specific street address format for the user. For country codes "US", "CA", "MX", "GB", "IE", "AU" it will return the house number before the address. Otherwise, it will return the house number after the address. If house number is provided, it will be prepended or appended to the address based on the country code. If the address is empty, it will return an empty string. If no house number is provided, it will return the address as is and expect the address field to contain both street name and house number in the correct order.
public static string GetCountrySpecificStreetAddress(this UserViewModel model)
Parameters
modelUserViewModelThe user view model.
Returns
- string
The formatted street address.
Examples
CountryCode = "US", HouseNumber = "123", Address = "Main Street" Output:
123 Main Street
CountryCode = "DK", HouseNumber = "456", Address = "Main Street" Output:
Main Street 456
GetCountrySpecificZipStateCity(UserViewModel)
Gets the country-specific zip and city format including the state where applicable. For country codes "US", "CA", "MX", "GB", "IE", "AU" it will return the city, state, and zip code. Otherwise, it will return the zip code and city.
public static string GetCountrySpecificZipStateCity(this UserViewModel model)
Parameters
modelUserViewModelThe user view model.
Returns
- string
The formatted address.
Examples
CountryCode = "US", State = "NY", ZipCode = "10014", City = "New York", Output:
New York, NY 10014
CountryCode = "DK", State = "", ZipCode = "2100", City = "Copenhagen", Output:
2100 Copenhagen
GetDeleteUserLink(UserViewModel, int)
Gets the delete user link for the specified user.
public static string? GetDeleteUserLink(this UserViewModel model, int pageId)
Parameters
modelUserViewModelThe UserViewModel instance.
pageIdintThe page ID.
Returns
- string
The delete user link if the
modelis not null; otherwise, null.
GetDeliveryAddresses(UserViewModel)
Retrieves a collection of user addresses allowed for delivery.
public static IEnumerable<AddressViewModel> GetDeliveryAddresses(this UserViewModel model)
Parameters
modelUserViewModelThe user view model.
Returns
- IEnumerable<AddressViewModel>
An enumerable collection of AddressViewModel.
GetResendInvitationLink(UserViewModel, int)
Gets the resend invitation link for the specified user.
public static string? GetResendInvitationLink(this UserViewModel model, int pageId)
Parameters
modelUserViewModelThe UserViewModel instance.
pageIdintThe page ID.
Returns
- string
The delete user link if the
modelis not null; otherwise, null.
GetStatus(UserViewModel)
Gets the status of the user - whether the user is active, has a pending invitation, or is inactive (not active and no invitation timestamp).
public static UserStatusType GetStatus(this UserViewModel model)
Parameters
modelUserViewModelThe UserViewModel instance.
Returns
- UserStatusType
A UserStatusType
modelis not null; otherwise, null.
GetTwoLetterInitials(UserViewModel)
Generates a two-letter uppercase initial string based on the user's name information.
public static string? GetTwoLetterInitials(this UserViewModel model)
Parameters
modelUserViewModelThe UserViewModel instance containing name data.
Returns
- string
A two-character string representing the user's initials:
-
If both
FirstNameandLastNameare provided, the first character of each is used. -
If only
Nameis provided and contains two words, the first character of each word is used. -
If
Nameis a single word with at least two characters, the first two characters are used. -
If
Nameis a single character, that character is used followed by 'X'. -
If no name data is available, returns
NN.
-
If both
Examples
For FirstName = "Jane" and LastName = "Doe", returns "JD".
For Name = "John Smith", returns "JS".
For Name = "Alice", returns "AL".
For Name = "Q", returns "QX".
For empty input, returns NN.
GetUsersWithSameUserName(UserViewModel)
Retrieves a collection of other users associated with the specified user based on the user name.
public static IEnumerable<UserViewModel> GetUsersWithSameUserName(this UserViewModel model)
Parameters
modelUserViewModelThe user view model.
Returns
- IEnumerable<UserViewModel>
An enumerable collection of UserViewModel.
TryGetImageFile(UserViewModel, out ImageFileViewModel?)
Tries to get the ImageFileViewModel for the Image.
public static bool TryGetImageFile(this UserViewModel viewModel, out ImageFileViewModel? image)
Parameters
viewModelUserViewModelThe user view model.
imageImageFileViewModelWhen this method returns
true, it contains the ImageFileViewModel object, otherwisenull.