Table of Contents

Class UserCreateViewModelExtensions

Namespace
Dynamicweb.Users.Frontend.UserCreate
Assembly
Dynamicweb.Users.dll

Extension methods for UserCreateViewModel.

public static class UserCreateViewModelExtensions
Inheritance
UserCreateViewModelExtensions
Inherited Members

Examples

Razor template usage:

@inherits ViewModelTemplate<Dynamicweb.Users.Frontend.UserCreate.UserCreateViewModel> @using Dynamicweb.Users.Frontend.UserCreate

@{ var action = Model.GetCreateUserLink(Pageview.Page.ID); // "/?ID=123&Cmd=CreateUser" var customers = Model.GetImpersonatableCustomerNumbers(); // e.g., ["10001","20002"] }

<form method="post" action="@action"> <label for="Email">Email</label> <input type="email" id="Email" name="Email" value="@Model.Email" required />

@* Optional: only meaningful for authenticated creators *@ @if (customers?.Any() == true) { <label for="CustomerNumber">Customer</label> <select id="CustomerNumber" name="CustomerNumber"> <option value="">(Same as my account)</option> @foreach (var c in customers) { <option>@c&lt;/option&gt; } </select> }

<button type="submit">Create account</button> </form>

Remarks

These helpers simplify posting the create-account form and, when an authenticated creator is present, retrieving the set of customer numbers they’re allowed to assign.

The most common usage is calling GetCreateUserLink(UserCreateViewModel, int) in a Razor template to set the form action, and GetImpersonatableCustomerNumbers(UserCreateViewModel) to populate an optional customer selector for administrators.

Methods

Gets a form action URL for creating a user (?Cmd=CreateUser).

public static string? GetCreateUserLink(this UserCreateViewModel model, int pageId)

Parameters

model UserCreateViewModel

The UserCreateViewModel instance from the template. May be null.

pageId int

The ID of the page hosting the UserCreate module (typically Pageview.Page.ID).

Returns

string

A URL like /?ID={pageId}&Cmd=CreateUser when model is not null;

This is a safe accessor — it returns null if model is null. Use it as the action of your account-creation form.

GetImpersonatableCustomerNumbers(UserCreateViewModel)

Returns the set of unique customer numbers the current user is allowed to assign.

public static ICollection<string> GetImpersonatableCustomerNumbers(this UserCreateViewModel model)

Parameters

model UserCreateViewModel

The UserCreateViewModel instance from the template. The method does not read state from this parameter; it exists to make the call site ergonomic in Razor (e.g., Model.GetImpersonatableCustomerNumbers()).

Returns

ICollection<string>

A case-insensitive collection of customer numbers the current (or impersonating) user can assign. Returns an empty collection when there is no logged-in user.

Remarks

Use this to populate an optional customer selector when authenticated administrators create users. The result includes the creator’s own customer number (if any) and those they’re permitted to impersonate.

To top