CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
Fakes/Server/DataPortal/PrimitiveCriteriaSingle.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="PrimitiveCriteriaSingle.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>no summary</summary>
7//-----------------------------------------------------------------------
8using System.Collections.Generic;
9using System.Text;
10
11using Csla;
12using System;
13using Csla.Core;
14
16{
17#if TESTING
18 [System.Diagnostics.DebuggerNonUserCode]
19#endif
21 public class PrimitiveCriteriaSingle : BusinessBase<PrimitiveCriteriaSingle>
22 {
23 #region Business Methods
24
25 public static readonly PropertyInfo<int> IdProperty = RegisterProperty<int>(c => c.Id);
26 public int Id
27 {
28 get { return GetProperty(IdProperty); }
29 set { SetProperty(IdProperty, value); }
30 }
31
32 private static PropertyInfo<string> MethodCalledProperty = RegisterProperty<string>(c => c.MethodCalled);
33 public string MethodCalled
34 {
35 get { return GetProperty(MethodCalledProperty); }
36 set { SetProperty(MethodCalledProperty, value); }
37 }
38
39 protected override object GetIdValue()
40 {
41 return Id;
42 }
43
44 #endregion
45
47 { }
48
49 #region Data Access
50
51 #region DataPortal_Create
52
53 protected void DataPortal_Create(int id)
54 {
55 DoCreate(id);
56 }
57
58 private void DoCreate(int id)
59 {
60 Id = id;
62 TestResults.Add("PrimitiveCriteriaSingle", "Created");
63 MethodCalled = "Created";
64 if (id == 9999)
65 throw new Exception("Bad data");
66 }
67
68 #endregion
69
70 #region DataPortal_Fetch
71
72
73 private void DataPortal_Fetch(int id)
74 {
75 DoFetch(id);
76 }
77
78 private void DataPortal_Fetch(string id)
79 {
80 DoFetch(int.Parse(id));
81 }
82
83 private void DataPortal_Fetch(Guid id)
84 {
85 DoFetch(1234);
86 }
87
88 private void DoFetch(int id)
89 {
90 Id = id;
91 TestResults.Reinitialise();
92 TestResults.Add("PrimitiveCriteriaSingle", "Fetched");
93 MethodCalled = "Fetched";
94 if (id == 9999)
95 throw new Exception("Bad data");
96 }
97
98 #endregion
99
100 #region DataPortal_Insert / DataPortal_Update / DataPortal_Delete
101
102 [Insert]
103 protected void DataPortal_Insert()
104 {
105 DoInsertUpdate(false);
106 }
107
108 private void DoInsertUpdate(bool isUpdate)
109 {
110 var insertOrUpdate = isUpdate ? "Updated" : "Inserted";
111
113 TestResults.Add("PrimitiveCriteriaSingle", insertOrUpdate);
114 MethodCalled = insertOrUpdate;
115 }
116
117
118
119 #endregion
120
121
122 [Delete]
123 private void DataPortal_Delete(int id)
124 {
126 TestResults.Add("PrimitiveCriteriaSingle", "Deleted");
127 MethodCalled = "Deleted+" + id.ToString();
128 }
129
130 #endregion
131 }
132}
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
Maintains metadata about a property.
override object GetIdValue()
Override this method to return a unique identifying value for this object.
Static dictionary-like class that offers similar functionality to GlobalContext This is used in tests...
Definition: TestResults.cs:21
static void Reinitialise()
Reinitialise the dictionary, clearing any existing results, ready for the next test
Definition: TestResults.cs:69
static void Add(string key, string value)
Add an item to the test results, to indicate an outcome of a particular operation
Definition: TestResults.cs:29
@ Serializable
Prevents updating or inserting until the transaction is complete.
@ Delete
Delete operation.