CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
Csla.Blazor.ViewModel< T > Class Template Reference

Base type for creating your own viewmodel. More...

Public Member Functions

 ViewModel (ApplicationContext applicationContext)
 Creates an instance of the type. More...
 
async Task< T > RefreshAsync (Func< Task< T > > factory)
 Refresh the Model More...
 
async Task SaveAsync ()
 Saves the Model More...
 
IPropertyInfo GetPropertyInfo< P > (Expression< Func< P > > property)
 Get a PropertyInfo object for a property. More...
 
IPropertyInfo GetPropertyInfo< P > (Expression< Func< P > > property, string id)
 Get a PropertyInfo object for a property. More...
 
IPropertyInfo GetPropertyInfo (string propertyName)
 Get a PropertyInfo object for a property of the Model. More...
 
IPropertyInfo GetPropertyInfo (string propertyName, string id)
 Get a PropertyInfo object for a property of the Model. More...
 
bool CanCreateObject ()
 Gets a value indicating whether the current user is authorized to create an instance of the business domain type More...
 
bool CanGetObject ()
 Gets a value indicating whether the current user is authorized to retrieve an instance of the business domain type More...
 
bool CanEditObject ()
 Gets a value indicating whether the current user is authorized to edit/save an instance of the business domain type More...
 
bool CanDeleteObject ()
 Gets a value indicating whether the current user is authorized to delete an instance of the business domain type More...
 

Protected Member Functions

virtual void OnModelChanging (T oldValue, T newValue)
 Raises the ModelChanging event More...
 
virtual void OnModelChanged ()
 Raises the ModelChanged event More...
 
virtual void OnModelPropertyChanged (string propertyName)
 Raises the ModelPropertyChanged event More...
 
virtual async Task< T > DoSaveAsync ()
 Override to provide custom Model save behavior More...
 

Properties

ApplicationContext ApplicationContext [get]
 Gets the current ApplicationContext instance. More...
 
Model [getset]
 Gets or sets the Model object. More...
 
string ViewModelErrorText [getprotected set]
 Gets any error text generated by refresh or save operations More...
 
virtual string ModelErrorText [get]
 Gets the first validation error message from the Model More...
 
Exception Exception [get]
 Gets the last exception caught by the viewmodel during refresh or save operations. More...
 

Events

Action Saved
 Event raised after Model has been saved More...
 
Action< T, T > ModelChanging
 Event raised when Model is changing More...
 
Action ModelChanged
 Event raised when Model has changed More...
 
PropertyChangedEventHandler ModelPropertyChanged
 Event raised when the Model object raises its PropertyChanged event More...
 

Detailed Description

Base type for creating your own viewmodel.

Definition at line 21 of file Csla.Blazor/ViewModel.cs.

Constructor & Destructor Documentation

◆ ViewModel()

Csla.Blazor.ViewModel< T >.ViewModel ( ApplicationContext  applicationContext)

Creates an instance of the type.

Parameters
applicationContext

Definition at line 32 of file Csla.Blazor/ViewModel.cs.

Member Function Documentation

◆ CanCreateObject()

bool Csla.Blazor.ViewModel< T >.CanCreateObject ( )

Gets a value indicating whether the current user is authorized to create an instance of the business domain type

Returns

Definition at line 292 of file Csla.Blazor/ViewModel.cs.

◆ CanDeleteObject()

bool Csla.Blazor.ViewModel< T >.CanDeleteObject ( )

Gets a value indicating whether the current user is authorized to delete an instance of the business domain type

Returns

Definition at line 325 of file Csla.Blazor/ViewModel.cs.

◆ CanEditObject()

bool Csla.Blazor.ViewModel< T >.CanEditObject ( )

Gets a value indicating whether the current user is authorized to edit/save an instance of the business domain type

Returns

Definition at line 314 of file Csla.Blazor/ViewModel.cs.

◆ CanGetObject()

bool Csla.Blazor.ViewModel< T >.CanGetObject ( )

Gets a value indicating whether the current user is authorized to retrieve an instance of the business domain type

Returns

Definition at line 303 of file Csla.Blazor/ViewModel.cs.

◆ DoSaveAsync()

virtual async Task< T > Csla.Blazor.ViewModel< T >.DoSaveAsync ( )
protectedvirtual

Override to provide custom Model save behavior

Returns

Definition at line 148 of file Csla.Blazor/ViewModel.cs.

◆ GetPropertyInfo() [1/2]

IPropertyInfo Csla.Blazor.ViewModel< T >.GetPropertyInfo ( string  propertyName)

Get a PropertyInfo object for a property of the Model.

PropertyInfo provides access to the metastate of the property.

Parameters
propertyNameProperty name
Returns

Definition at line 223 of file Csla.Blazor/ViewModel.cs.

◆ GetPropertyInfo() [2/2]

IPropertyInfo Csla.Blazor.ViewModel< T >.GetPropertyInfo ( string  propertyName,
string  id 
)

Get a PropertyInfo object for a property of the Model.

PropertyInfo provides access to the metastate of the property.

Parameters
propertyNameProperty name
idUnique identifier for property in list or array
Returns

Definition at line 237 of file Csla.Blazor/ViewModel.cs.

◆ GetPropertyInfo< P >() [1/2]

IPropertyInfo Csla.Blazor.ViewModel< T >.GetPropertyInfo< P > ( Expression< Func< P > >  property)

Get a PropertyInfo object for a property.

PropertyInfo provides access to the metastate of the property.

Parameters
propertyProperty expression
Returns

Definition at line 188 of file Csla.Blazor/ViewModel.cs.

◆ GetPropertyInfo< P >() [2/2]

IPropertyInfo Csla.Blazor.ViewModel< T >.GetPropertyInfo< P > ( Expression< Func< P > >  property,
string  id 
)

Get a PropertyInfo object for a property.

PropertyInfo provides access to the metastate of the property.

Parameters
propertyProperty expression
idUnique identifier for property in list or array
Returns

Definition at line 206 of file Csla.Blazor/ViewModel.cs.

◆ OnModelChanged()

virtual void Csla.Blazor.ViewModel< T >.OnModelChanged ( )
protectedvirtual

Raises the ModelChanged event

Definition at line 73 of file Csla.Blazor/ViewModel.cs.

◆ OnModelChanging()

virtual void Csla.Blazor.ViewModel< T >.OnModelChanging ( oldValue,
newValue 
)
protectedvirtual

Raises the ModelChanging event

Parameters
oldValueOld Model value
newValueNew Model value

Definition at line 60 of file Csla.Blazor/ViewModel.cs.

◆ OnModelPropertyChanged()

virtual void Csla.Blazor.ViewModel< T >.OnModelPropertyChanged ( string  propertyName)
protectedvirtual

Raises the ModelPropertyChanged event

Parameters
propertyName

Definition at line 82 of file Csla.Blazor/ViewModel.cs.

◆ RefreshAsync()

async Task< T > Csla.Blazor.ViewModel< T >.RefreshAsync ( Func< Task< T > >  factory)

Refresh the Model

Parameters
factoryAsync data portal or factory method

Definition at line 91 of file Csla.Blazor/ViewModel.cs.

◆ SaveAsync()

async Task Csla.Blazor.ViewModel< T >.SaveAsync ( )

Saves the Model

Returns

Definition at line 118 of file Csla.Blazor/ViewModel.cs.

Property Documentation

◆ ApplicationContext

Gets the current ApplicationContext instance.

Definition at line 26 of file Csla.Blazor/ViewModel.cs.

◆ Exception

Exception Csla.Blazor.ViewModel< T >.Exception
get

Gets the last exception caught by the viewmodel during refresh or save operations.

Definition at line 284 of file Csla.Blazor/ViewModel.cs.

◆ Model

T Csla.Blazor.ViewModel< T >.Model
getset

Gets or sets the Model object.

Definition at line 165 of file Csla.Blazor/ViewModel.cs.

◆ ModelErrorText

virtual string Csla.Blazor.ViewModel< T >.ModelErrorText
getprotected

Gets the first validation error message from the Model

Definition at line 267 of file Csla.Blazor/ViewModel.cs.

◆ ViewModelErrorText

string Csla.Blazor.ViewModel< T >.ViewModelErrorText
getprotected set

Gets any error text generated by refresh or save operations

Definition at line 261 of file Csla.Blazor/ViewModel.cs.

Event Documentation

◆ ModelChanged

Action Csla.Blazor.ViewModel< T >.ModelChanged

Event raised when Model has changed

Definition at line 48 of file Csla.Blazor/ViewModel.cs.

◆ ModelChanging

Action<T, T> Csla.Blazor.ViewModel< T >.ModelChanging

Event raised when Model is changing

Definition at line 44 of file Csla.Blazor/ViewModel.cs.

◆ ModelPropertyChanged

PropertyChangedEventHandler Csla.Blazor.ViewModel< T >.ModelPropertyChanged

Event raised when the Model object raises its PropertyChanged event

Definition at line 53 of file Csla.Blazor/ViewModel.cs.

◆ Saved

Action Csla.Blazor.ViewModel< T >.Saved

Event raised after Model has been saved

Definition at line 40 of file Csla.Blazor/ViewModel.cs.