Table of Contents

Class ItemViewModel

Namespace
Dynamicweb.Frontend
Assembly
Dynamicweb.dll

ItemViewModel represents the rendering context used when an item is rendered.

public class ItemViewModel : ViewModelBase
Inheritance
ItemViewModel
Inherited Members

Constructors

ItemViewModel()

Initializes a new instance of the ItemViewModel class.

public ItemViewModel()

Properties

Fields

Gets a list of fields and their values for this item.

public IList<ItemFieldViewModel> Fields { get; set; }

Property Value

IList<ItemFieldViewModel>

A list ItemFieldViewModel with system name and value of the fields in this item.

Id

Gets the item id.

public string Id { get; set; }

Property Value

string

Gets a link (URL) to the page or paragraph that this item is attached to. If the item is not a page or paragraph this property is empty

public string Link { get; set; }

Property Value

string

The link. e.g. '/home' (Default.aspx?ID=1 if not using friendly URLs) or '/home#345'

PageID

Gets the page id if the item is attached to a page, row or a paragraph. If the item is attached to an area or user, this field is 0

public int PageID { get; set; }

Property Value

int

the page id.

ParagraphID

Gets the paragraph id if the item is attached to a paragraph. If the item is attached to an area, page, row or user, this field is 0

public int ParagraphID { get; set; }

Property Value

int

The paragraph id.

SystemName

Gets or sets the system name of the item type.

public string SystemName { get; set; }

Property Value

string

The system name.

Methods

GetBoolean(string)

Gets the boolean value of the field if the field is a boolean.

public bool GetBoolean(string systemName)

Parameters

systemName string

The field system name.

Returns

bool

true or false, which reflects the value stored in specified field. Fallback is default boolean value GetValueOrDefault()

GetColor(string)

Gets a color view model if the field is a color field

public ColorViewModel GetColor(string systemName)

Parameters

systemName string

The field system name.

Returns

ColorViewModel

Hex value of a color starts with # char.

Remarks

For the transparent color method returns an empty string.

GetDateTime(string)

Gets the datetime value of the field if the field is a datetime field.

public DateTime GetDateTime(string systemName)

Parameters

systemName string

The field system name.

Returns

DateTime

System.DateTime.

GetDecimal(string)

Gets the decimal value of the field if the field is a numeric field.

public decimal GetDecimal(string systemName)

Parameters

systemName string

The field system name.

Returns

decimal

System.Decimal.

GetDouble(string)

Gets the double value of the field if the field is a numeric field.

public double GetDouble(string systemName)

Parameters

systemName string

The field system name.

Returns

double

System.Double.

GetField(string)

Gets the field.

public ItemFieldViewModel GetField(string systemName)

Parameters

systemName string

The field system name.

Returns

ItemFieldViewModel

ItemFieldModel.

GetFile(string)

Gets a file view model of the field if the field is a file field.

public FileViewModel GetFile(string systemName)

Parameters

systemName string

The field system name.

Returns

FileViewModel

FileViewModel.

GetFiles(string)

Gets a list of file view models of the field if the field is a file list field.

public IList<FileViewModel> GetFiles(string systemName)

Parameters

systemName string

The field system name.

Returns

IList<FileViewModel>

IList(Of FileViewModel).

GetGeolocation(string)

Gets a geolocation view mode of the field if the field is a geo location field.

public GeolocationViewModel GetGeolocation(string systemName)

Parameters

systemName string

The field system name.

Returns

GeolocationViewModel

GeolocationViewModel.

GetGoogleFont(string)

Gets a google font view model of the field if the field is a font field.

public GoogleFontViewModel GetGoogleFont(string systemName)

Parameters

systemName string

The field system name.

Returns

GoogleFontViewModel

GoogleFontViewModel

GetInt32(string)

Gets the int value of the field if the field is a numeric field.

public int GetInt32(string systemName)

Parameters

systemName string

The field system name.

Returns

int

System.Int32.

GetInt64(string)

Gets the int64 value of the field if the field is a numeric field.

public long GetInt64(string systemName)

Parameters

systemName string

The field system name.

Returns

long

System.Int64.

GetItem(string)

Gets an item view model of the field if the field is an item field.

public ItemViewModel GetItem(string systemName)

Parameters

systemName string

The field system name.

Returns

ItemViewModel

ItemViewModel.

GetItems(string)

Gets a list of item view model of the field if the field is an item relation list.

public IList<ItemViewModel> GetItems(string systemName)

Parameters

systemName string

The field system name.

Returns

IList<ItemViewModel>

IList(Of ItemViewModel).

Gets a link view model if the field is a link field

public LinkViewModel GetLink(string systemName)

Parameters

systemName string

The field system name.

Returns

LinkViewModel

See LinkViewModel

GetList(string)

Gets a list view model if the field is a list field

public ListViewModel GetList(string systemName)

Parameters

systemName string

The field system name.

Returns

ListViewModel

GetRawValue(string)

Gets the raw unmodified value from the database without any parsing

public object GetRawValue(string systemName)

Parameters

systemName string

System name of the field to return value for

Returns

object

An object of the values underlying database type. Int, String, Boolean etc. Never another viewmodel or object

GetRawValueString(string)

Gets the raw unmodified value from the database without any parsing but converted to string

public string GetRawValueString(string systemName)

Parameters

systemName string

System name of the field to return value for

Returns

string

A string of the underlying raw value.

GetRawValueString(string, string)

Gets the raw unmodified value from the database without any parsing but converted to string

public string GetRawValueString(string systemName, string defaultValue)

Parameters

systemName string

System name of the field to return value for

defaultValue string

Value to return if the field does not return any value

Returns

string

A string of the underlying raw value.

GetString(string)

Gets the value of the field as string.

public string GetString(string systemName)

Parameters

systemName string

The field system name.

Returns

string

System.String. ToString is called on whatever object is returned on the field

GetString(string, string)

Gets the value of the field in string format. Returns the default value if the field value is null or empty string.

public string GetString(string systemName, string defaultValue)

Parameters

systemName string

System name of the field to return value for

defaultValue string

Value to return if the field does not return any value

Returns

string

A string of the underlying raw value.

GetUsers(string)

Gets a list of user view models if the field is a user field.

public IList<UserViewModel> GetUsers(string systemName)

Parameters

systemName string

The field system name.

Returns

IList<UserViewModel>

IList(Of UserViewModel).

GetValue(string)

Gets the value of the field no matter its underlying type.

public object GetValue(string systemName)

Parameters

systemName string

The field system name.

Returns

object

System.Object. The instance of the object would be one of the item viewmodel types

GetValue<T>(string)

Retrieves the value of a field specified by the system name and converts it to the specified type.

public T GetValue<T>(string systemName) where T : class

Parameters

systemName string

The system name of field whose value is to be retrieved.

Returns

T

The value of the specified field as type T, or null if the field is not found or the value cannot be converted to type T.

Type Parameters

T

The type to which the value should be converted. This type is one of the item field view models.

Remarks

This method uses the GetField(string) method to retrieve the field and then attempts to get its value converted to the specified type. If the field does not exist or the value is not of the expected type, null is returned.

TryGetColor(string, out ColorViewModel)

Using the systemName to retrieve an itemfield using GetColor(string). If GetColor(string) returns null, the methods returns false, otherwise returning true.

public bool TryGetColor(string systemName, out ColorViewModel color)

Parameters

systemName string

Used to look up the corresponding ColorViewModel if it exists on the item.

color ColorViewModel

The outColorViewModel value from the method.

Returns

bool

true if color is not null, otherwise false

TryGetDateTime(string, out DateTime)

public bool TryGetDateTime(string systemName, out DateTime dateTime)

Parameters

systemName string
dateTime DateTime

Returns

bool

TryGetField(string, out ItemFieldViewModel)

Using the systemName to retrieve an itemfield using GetField(string). If GetField(string) returns null, the methods returns false, otherwise returning true.

public bool TryGetField(string systemName, out ItemFieldViewModel itemField)

Parameters

systemName string

Used to look up the corresponding ItemFieldViewModel if it exists on the item.

itemField ItemFieldViewModel

The outItemFieldViewModel value from the method.

Returns

bool

true if itemField is not null, otherwise false

TryGetFile(string, out FileViewModel)

Using the systemName to retrieve an itemfield using GetFile(string). If GetFile(string) returns null, the methods returns false, otherwise returning true.

public bool TryGetFile(string systemName, out FileViewModel file)

Parameters

systemName string

Used to look up the corresponding FileViewModel if it exists on the item.

file FileViewModel

The outFileViewModel value from the method.

Returns

bool

true if file is not null, otherwise false

TryGetFiles(string, out IList<FileViewModel>)

Using the systemName to retrieve an itemfield using GetFiles(string). If GetFiles(string) returns null, the methods returns false, otherwise returning true.

public bool TryGetFiles(string systemName, out IList<FileViewModel> files)

Parameters

systemName string

Used to look up the corresponding IList<T> if it exists on the item.

files IList<FileViewModel>

The outIList<T> value from the method.

Returns

bool

true if files is not null, otherwise false

TryGetGeolocation(string, out GeolocationViewModel)

Using the systemName to retrieve an itemfield using GetGeolocation(string). If GetGeolocation(string) returns null, the methods returns false, otherwise returning true.

public bool TryGetGeolocation(string systemName, out GeolocationViewModel geolocation)

Parameters

systemName string

Used to look up the corresponding GeolocationViewModel if it exists on the item.

geolocation GeolocationViewModel

The outGeolocationViewModel value from the method.

Returns

bool

true if geolocation is not null, otherwise false

TryGetGoogleFont(string, out GoogleFontViewModel)

Using the systemName to retrieve an itemfield using GetGoogleFont(string). If GetGoogleFont(string) returns null, the methods returns false, otherwise returning true.

public bool TryGetGoogleFont(string systemName, out GoogleFontViewModel googleFont)

Parameters

systemName string

Used to look up the corresponding ItemFieldViewModel if it exists on the item.

googleFont GoogleFontViewModel

The GoogleFontViewModel return if existing.

Returns

bool

true if googleFont is not null, otherwise false

TryGetImageFile(string, out ImageFileViewModel)

Get image file based on the systemName and return true if an image file exists on the item and false if it doesn't.

public bool TryGetImageFile(string systemName, out ImageFileViewModel image)

Parameters

systemName string

Name of the item field being searched for.

image ImageFileViewModel

Output-parameter, will be null if no image was found and otherwise the value retrieved.

Returns

bool

Returns true if an image exists, otherwise false. The output parameter image will be null if no image was found.

TryGetImageFiles(string, out IEnumerable<ImageFileViewModel>)

Get image files based on the systemName and return true if imagefiles exists on the item and false if there are not.

public bool TryGetImageFiles(string systemName, out IEnumerable<ImageFileViewModel> images)

Parameters

systemName string

Name of the item field being searched for.

images IEnumerable<ImageFileViewModel>

Output-parameter, will be null if no images were found and otherwise the value retrieved.

Returns

bool

Returns true if images exists, otherwise false. The output parameter images will be null if no image was found.

TryGetItem(string, out ItemViewModel)

Using the systemName to retrieve an itemfield using GetItem(string). If GetItem(string) returns null, the methods returns false, otherwise returning true.

public bool TryGetItem(string systemName, out ItemViewModel item)

Parameters

systemName string

Used to look up the corresponding ItemViewModel if it exists on the item.

item ItemViewModel

The outItemViewModel value from the method.

Returns

bool

true if item is not null, otherwise false

TryGetItems(string, out IList<ItemViewModel>)

public bool TryGetItems(string systemName, out IList<ItemViewModel> items)

Parameters

systemName string
items IList<ItemViewModel>

Returns

bool

Using the systemName to retrieve an itemfield using GetLink(string). If GetLink(string) returns null, the methods returns false, otherwise returning true.

public bool TryGetLink(string systemName, out LinkViewModel link)

Parameters

systemName string

Used to look up the corresponding LinkViewModel if it exists on the item.

link LinkViewModel

The outLinkViewModel value from the method.

Returns

bool

true if link is not null, otherwise false

TryGetList(string, out ListViewModel)

Using the systemName to retrieve an itemfield using GetList(string). If GetList(string) returns null, the methods returns false, otherwise returning true.

public bool TryGetList(string systemName, out ListViewModel list)

Parameters

systemName string

Used to look up the corresponding ListViewModel if it exists on the item.

list ListViewModel

The outListViewModel value from the method.

Returns

bool

true if list is not null, otherwise false

TryGetString(string, out string)

Using the systemName parameter new to retrieve the corresponding value. If the value retrieved is different from null and is not an empty string, the method returns true, otherwise false.

public bool TryGetString(string systemName, out string value)

Parameters

systemName string

The field system name.

value string

output value based on the systemname when calling GetField(string)

Returns

bool

TryGetUsers(string, out IList<UserViewModel>)

public bool TryGetUsers(string systemName, out IList<UserViewModel> users)

Parameters

systemName string
users IList<UserViewModel>

Returns

bool

TryGetValue<T>(string, out T)

TryGet for Value. Using the systemName parameter to retrieve corresponding value, returning true if the value is not null, otherwise false.

public bool TryGetValue<T>(string systemName, out T value) where T : class

Parameters

systemName string

Systemname from which to retrieve a given value of type T

value T

Return value of Type T

Returns

bool

Type Parameters

T

See Also

To top