CSLA.NET 5.4.2
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 (IDataPortal< T > dataPortal)
 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...
 

Static Public Member Functions

static bool CanCreateObject ()
 Gets a value indicating whether the current user is authorized to create an instance of the business domain type More...
 
static bool CanGetObject ()
 Gets a value indicating whether the current user is authorized to retrieve an instance of the business domain type More...
 
static bool CanEditObject ()
 Gets a value indicating whether the current user is authorized to edit/save an instance of the business domain type More...
 
static 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

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 22 of file Csla.Blazor/ViewModel.cs.

Constructor & Destructor Documentation

◆ ViewModel()

Csla.Blazor.ViewModel< T >.ViewModel ( IDataPortal< T >  dataPortal)

Creates an instance of the type

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

Member Function Documentation

◆ CanCreateObject()

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

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

Returns

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

◆ CanDeleteObject()

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

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

Returns

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

◆ CanEditObject()

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

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

Returns

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

◆ CanGetObject()

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

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

Returns

Definition at line 294 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 140 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 214 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 228 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 179 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 197 of file Csla.Blazor/ViewModel.cs.

◆ OnModelChanged()

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

Raises the ModelChanged event

Definition at line 62 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 49 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 71 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 88 of file Csla.Blazor/ViewModel.cs.

◆ SaveAsync()

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

Saves the Model

Returns

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

Property Documentation

◆ Exception

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

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

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

◆ Model

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

Gets or sets the Model object.

Definition at line 157 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 258 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 252 of file Csla.Blazor/ViewModel.cs.

Event Documentation

◆ ModelChanged

Action Csla.Blazor.ViewModel< T >.ModelChanged

Event raised when Model has changed

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

◆ ModelChanging

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

Event raised when Model is changing

Definition at line 33 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 42 of file Csla.Blazor/ViewModel.cs.

◆ Saved

Action Csla.Blazor.ViewModel< T >.Saved

Event raised after Model has been saved

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