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
Link
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
stringThe field system name.
Returns
- bool
true
orfalse
, 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
stringThe 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
stringThe 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
stringThe 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
stringThe field system name.
Returns
- double
System.Double.
GetField(string)
Gets the field.
public ItemFieldViewModel GetField(string systemName)
Parameters
systemName
stringThe 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
stringThe 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
stringThe 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
stringThe 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
stringThe 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
stringThe 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
stringThe 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
stringThe 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
stringThe field system name.
Returns
- IList<ItemViewModel>
IList(Of ItemViewModel).
GetLink(string)
Gets a link view model if the field is a link field
public LinkViewModel GetLink(string systemName)
Parameters
systemName
stringThe field system name.
Returns
GetList(string)
Gets a list view model if the field is a list field
public ListViewModel GetList(string systemName)
Parameters
systemName
stringThe field system name.
Returns
GetRawValue(string)
Gets the raw unmodified value from the database without any parsing
public object GetRawValue(string systemName)
Parameters
systemName
stringSystem 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
stringSystem 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
stringSystem name of the field to return value for
defaultValue
stringValue 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
stringThe 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
stringSystem name of the field to return value for
defaultValue
stringValue 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
stringThe 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
stringThe 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
stringThe 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 typeT
.
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
stringUsed to look up the corresponding ColorViewModel if it exists on the item.
color
ColorViewModelThe
out
ColorViewModel value from the method.
Returns
- bool
true
ifcolor
is not null, otherwisefalse
TryGetDateTime(string, out DateTime)
public bool TryGetDateTime(string systemName, out DateTime dateTime)
Parameters
Returns
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
stringUsed to look up the corresponding ItemFieldViewModel if it exists on the item.
itemField
ItemFieldViewModelThe
out
ItemFieldViewModel value from the method.
Returns
- bool
true
ifitemField
is not null, otherwisefalse
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
stringUsed to look up the corresponding FileViewModel if it exists on the item.
file
FileViewModelThe
out
FileViewModel value from the method.
Returns
- bool
true
iffile
is not null, otherwisefalse
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
stringUsed to look up the corresponding IList<T> if it exists on the item.
files
IList<FileViewModel>The
out
IList<T> value from the method.
Returns
- bool
true
iffiles
is not null, otherwisefalse
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
stringUsed to look up the corresponding GeolocationViewModel if it exists on the item.
geolocation
GeolocationViewModelThe
out
GeolocationViewModel value from the method.
Returns
- bool
true
ifgeolocation
is not null, otherwisefalse
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
stringUsed to look up the corresponding ItemFieldViewModel if it exists on the item.
googleFont
GoogleFontViewModelThe GoogleFontViewModel return if existing.
Returns
- bool
true
ifgoogleFont
is not null, otherwisefalse
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
stringName of the item field being searched for.
image
ImageFileViewModelOutput-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 parameterimage
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
stringName 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 parameterimages
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
stringUsed to look up the corresponding ItemViewModel if it exists on the item.
item
ItemViewModelThe
out
ItemViewModel value from the method.
Returns
- bool
true
ifitem
is not null, otherwisefalse
TryGetItems(string, out IList<ItemViewModel>)
public bool TryGetItems(string systemName, out IList<ItemViewModel> items)
Parameters
systemName
stringitems
IList<ItemViewModel>
Returns
TryGetLink(string, out LinkViewModel)
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
stringUsed to look up the corresponding LinkViewModel if it exists on the item.
link
LinkViewModelThe
out
LinkViewModel value from the method.
Returns
- bool
true
iflink
is not null, otherwisefalse
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
stringUsed to look up the corresponding ListViewModel if it exists on the item.
list
ListViewModelThe
out
ListViewModel value from the method.
Returns
- bool
true
iflist
is not null, otherwisefalse
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
stringThe field system name.
value
stringoutput value based on the systemname when calling GetField(string)
Returns
TryGetUsers(string, out IList<UserViewModel>)
public bool TryGetUsers(string systemName, out IList<UserViewModel> users)
Parameters
systemName
stringusers
IList<UserViewModel>
Returns
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
stringSystemname from which to retrieve a given value of type T
value
TReturn value of Type
T
Returns
Type Parameters
T