9using System.Collections.Generic;
12using System.Threading.Tasks;
29 const int customerIDThrowsException = 99;
33 internal static Customer NewCustomer()
36 returnValue.Name =
"New";
37 returnValue.MarkAsChild();
41 private static PropertyInfo<int> IdProperty = RegisterProperty<int>(c=>c.Id,
"Customer Id", 0);
46 return GetProperty<int>(IdProperty);
50 SetProperty<int>(IdProperty, value);
54 private static PropertyInfo<string> NameProperty = RegisterProperty<string>(c=>c.Name,
"Customer Name",
"");
59 return GetProperty<string>(NameProperty);
63 SetProperty<string>(NameProperty, value);
67 private static PropertyInfo<string> MethodProperty = RegisterProperty<string>(c=>c.Method,
"Method",
"");
72 return GetProperty<string>(MethodProperty);
76 SetProperty<string>(MethodProperty, value);
81 private static PropertyInfo<SmartDate> DateCreatedProperty = RegisterProperty<SmartDate>(c=>c.DateCreated,
"Date Created On");
86 return GetProperty<SmartDate>(DateCreatedProperty).Text;
93 SetProperty<SmartDate>(DateCreatedProperty, test);
99 private static PropertyInfo<bool> ThrowExceptionProperty = RegisterProperty<bool>(c=>c.ThrowException,
"ThrowException",
false);
104 return GetProperty<bool>(ThrowExceptionProperty);
108 LoadProperty<bool>(ThrowExceptionProperty, value);
112 private static PropertyInfo<DateTimeOffset> DateTimeOffsetNullProperty = RegisterProperty<DateTimeOffset>(c=>c.DateTimeOffsetNull,
"DateTimeOffsetNull");
117 return GetProperty(DateTimeOffsetNullProperty);
121 LoadProperty(DateTimeOffsetNullProperty, value);
125 private static PropertyInfo<DateTimeOffset> DateTimeOffsetNotNullProperty = RegisterProperty<DateTimeOffset>(c=>c.DateTimeOffsetNotNull,
"DateTimeOffsetNotNull", DateTimeOffset.Now);
130 return GetProperty(DateTimeOffsetNotNullProperty);
134 LoadProperty(DateTimeOffsetNotNullProperty, value);
138 private static PropertyInfo<DateTimeOffset?> DateTimeOffsetNullableProperty = RegisterProperty<DateTimeOffset?>(c=>c.DateTimeOffsetNullable,
"DateTimeOffsetNullable");
143 return GetProperty(DateTimeOffsetNullableProperty);
147 LoadProperty(DateTimeOffsetNullableProperty, value);
156 return GetProperty(TypeProperty);
160 SetProperty(TypeProperty, value);
170 return GetProperty<CustomerContactList>(ContactsProperty);
188 _customerId = customerID;
191 private int _customerId;
203 base.OnGetState(info, mode);
204 info.AddValue(
"_customerId", _customerId);
208 base.OnSetState(info, mode);
209 _customerId = info.GetValue<
int>(
"_customerId");
215 LoadProperty(IdProperty, criteria);
216 LoadProperty(NameProperty,
"Customer Name for Id: " + criteria.ToString());
217 LoadProperty(DateCreatedProperty,
new SmartDate(
new DateTime(2000 + criteria, 1, 1)));
218 LoadProperty(ContactsProperty, childDataPortal.FetchChild(criteria));
219 LoadProperty(DateTimeOffsetNotNullProperty, DateTimeOffset.Now);
222 if (criteria == customerIDThrowsException)
223 throw new ApplicationException(
"Test for Silverlight DataSource Error!");
228 LoadProperty(IdProperty, criteria);
229 LoadProperty(NameProperty,
"New Customer for Id: " + criteria.ToString());
230 LoadProperty(DateCreatedProperty,
new SmartDate(DateTime.Today));
231 LoadProperty(DateTimeOffsetNotNullProperty, DateTimeOffset.Now);
232 LoadProperty(ContactsProperty, childDataPortal.FetchChild(0));
238 Method =
"Deleted Customer " + GetProperty<string>(NameProperty);
244 Method =
"Deleted Customer ID " + criteria.ToString();
250 Method =
"Inserted Customer " + GetProperty<string>(NameProperty);
251 contactsListDataPortal.UpdateChild(ReadProperty(ContactsProperty));
257 Method =
"Updating Customer " + GetProperty<string>(NameProperty);
258 contactsListDataPortal.UpdateChild(ReadProperty(ContactsProperty));
267 private async Task Create()
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.
FetchCriteria(int customerID)
override void OnGetState(Csla.Serialization.Mobile.SerializationInfo info, StateMode mode)
override void OnSetState(Csla.Serialization.Mobile.SerializationInfo info, StateMode mode)
void DataPortal_Fetch(int criteria, [Inject] IChildDataPortal< CustomerContactList > childDataPortal)
void DataPortal_DeleteSelf()
CustomerContactList Contacts
void DataPortal_Insert([Inject] IChildDataPortal< CustomerContactList > contactsListDataPortal)
DateTimeOffset DateTimeOffsetNull
DateTimeOffset? DateTimeOffsetNullable
DateTimeOffset DateTimeOffsetNotNull
override void AddBusinessRules()
void DataPortal_Update([Inject] IChildDataPortal< CustomerContactList > contactsListDataPortal)
void DataPortal_Create(int criteria, [Inject] IChildDataPortal< CustomerContactList > childDataPortal)
void DataPortal_Delete(int criteria)
Task CheckRulesAsync()
Invokes all rules for the business type.
Interface defining the members of the child data portal type.
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.