Class UserAddressViewModel
- Namespace
- Dynamicweb.Users.Frontend.UserAddresses
- Assembly
- Dynamicweb.Users.dll
View model for the UserAddresses edit view.
public sealed class UserAddressViewModel : ViewModelBase
- Inheritance
-
UserAddressViewModel
- Inherited Members
- Extension Methods
Examples
Razor template usage:
@inherits ViewModelTemplate<Dynamicweb.Users.Frontend.UserAddresses.UserAddressViewModel> @using Dynamicweb.Users.Frontend.UserAddresses
@{ var saveAction = Model.GetSaveAddressLink(Pageview.Page.ID); // "/?ID=123&Cmd=SaveAddress&AddressId={id}" var deleteAction = Model.GetDeleteAddressLink(Pageview.Page.ID); // "/?ID=123&Cmd=DeleteAddress&AddressId={id}" }
<form method="post" action="@saveAction"> <label for="Name">Name</label> <input id="Name" name="Name" value="@Model.Address.Name" required /> <!-- add other fields ... --> <button type="submit">Save</button> @if (Model.Result != UserAddressResultType.None) { <p class="form-message">@Translate(Model.Result.ToString())</p> } </form>
@if (Model.Address.Id > 0) { <form method="post" action="@deleteAction" onsubmit="return confirm('Delete this address?');"> <button class="btn btn-danger" type="submit">Delete</button> </form> }
Remarks
This model is provided to Razor templates in /Templates/Users/UserAddresses/Edit.
It exposes the address being edited, and the result of the most recent operation.
Templates typically render a form that posts to GetSaveAddressLink(UserAddressViewModel, int) and use Result to display success/error messages. A separate POST can target GetDeleteAddressLink(UserAddressViewModel, int) for deletion.
Properties
Address
Gets or sets the address being edited.
public required AddressViewModel Address { get; set; }
Property Value
Result
Gets or sets the outcome of the most recent operation.
public UserAddressResultType Result { get; set; }
Property Value
Remarks
Typical values: None, Success, InvalidEmail.