9using System.Collections.Generic;
22 const int customerIDThrowsException = 99;
26 internal static Customer NewCustomer()
29 returnValue.Name =
"New";
33 private static PropertyInfo<int> IdProperty = RegisterProperty<int>(c => c.Id,
"Customer Id", 0);
38 return GetProperty<int>(IdProperty);
42 SetProperty<int>(IdProperty, value);
46 private static PropertyInfo<string> NameProperty = RegisterProperty<string>(c => c.Name,
"Customer Name",
"");
51 return GetProperty<string>(NameProperty);
55 SetProperty<string>(NameProperty, value);
59 private static PropertyInfo<string> MethodProperty = RegisterProperty<string>(c => c.Method,
"Method",
"");
64 return GetProperty<string>(MethodProperty);
68 SetProperty<string>(MethodProperty, value);
91 private static PropertyInfo<bool> ThrowExceptionProperty = RegisterProperty<bool>(c => c.ThrowException,
"ThrowException",
false);
96 return GetProperty<bool>(ThrowExceptionProperty);
100 LoadProperty<bool>(ThrowExceptionProperty, value);
117 _customerId = customerID;
120 private int _customerId;
132 base.OnGetState(info, mode);
133 info.AddValue(
"_customerId", _customerId);
137 base.OnSetState(info, mode);
138 _customerId = info.GetValue<
int>(
"_customerId");
142 internal static Customer GetCustomer(
int customerID)
146 newCustomer.MarkOld();
152 LoadProperty(IdProperty, criteria);
153 LoadProperty(NameProperty,
"Customer Name for Id: " + criteria.ToString());
154 LoadProperty(DateCreatedProperty,
new Csla.
SmartDate(
new DateTime(2000 + criteria, 1, 1)));
156 if (criteria == customerIDThrowsException)
157 throw new ApplicationException(
"Test Error!");
162 LoadProperty(IdProperty, criteria);
163 LoadProperty(NameProperty,
"New Customer for Id: " + criteria.ToString());
164 LoadProperty(DateCreatedProperty,
new Csla.
SmartDate(DateTime.Today));
170 Method =
"Deleted Customer " + GetProperty<string>(NameProperty);
176 Method =
"Deleted Customer ID " + criteria.ToString();
182 Method =
"Inserted Customer " + GetProperty<string>(NameProperty);
188 Method =
"Updating Customer " + GetProperty<string>(NameProperty);
This is the base class from which most business objects will be derived.
Base type from which Criteria classes can be derived in a business class.
Maintains metadata about a property.
Business rule for a minimum value.
Object containing the serialization data for a specific object.
override void OnGetState(Csla.Serialization.Mobile.SerializationInfo info, StateMode mode)
override void OnSetState(Csla.Serialization.Mobile.SerializationInfo info, StateMode mode)
FetchCriteria(int customerID)
void DataPortal_Delete(int criteria)
void DataPortal_DeleteSelf()
void DataPortal_Create(int criteria)
override void AddBusinessRules()
void DataPortal_Fetch(int criteria)
StateMode
Indicates the reason the MobileFormatter functionality has been invoked.
@ Serializable
Prevents updating or inserting until the transaction is complete.
@ Update
Update operation (includes insert, update and delete self).
@ Delete
Delete operation.
Provides a date data type that understands the concept of an empty date value.
static bool TryParse(string value, ref SmartDate result)
Converts a string value into a SmartDate.