/
EntityTypeService.cs
289 lines (253 loc) · 13.2 KB
/
EntityTypeService.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Rock.CodeGeneration project
// Changes to this file will be lost when the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
// <copyright>
// Copyright by the Spark Development Network
//
// Licensed under the Rock Community License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.rockrms.com/license
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
//
using System;
using System.Linq;
using Rock.Data;
namespace Rock.Model
{
/// <summary>
/// EntityType Service class
/// </summary>
public partial class EntityTypeService : Service<EntityType>
{
/// <summary>
/// Initializes a new instance of the <see cref="EntityTypeService"/> class
/// </summary>
/// <param name="context">The context.</param>
public EntityTypeService(RockContext context) : base(context)
{
}
/// <summary>
/// Determines whether this instance can delete the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="errorMessage">The error message.</param>
/// <returns>
/// <c>true</c> if this instance can delete the specified item; otherwise, <c>false</c>.
/// </returns>
public bool CanDelete( EntityType item, out string errorMessage )
{
errorMessage = string.Empty;
if ( new Service<Attribute>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, Attribute.FriendlyTypeName );
return false;
}
if ( new Service<Audit>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, Audit.FriendlyTypeName );
return false;
}
if ( new Service<Auth>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, Auth.FriendlyTypeName );
return false;
}
if ( new Service<BinaryFileType>( Context ).Queryable().Any( a => a.StorageEntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, BinaryFileType.FriendlyTypeName );
return false;
}
if ( new Service<Category>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, Category.FriendlyTypeName );
return false;
}
if ( new Service<Communication>( Context ).Queryable().Any( a => a.MediumEntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, Communication.FriendlyTypeName );
return false;
}
if ( new Service<CommunicationTemplate>( Context ).Queryable().Any( a => a.MediumEntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, CommunicationTemplate.FriendlyTypeName );
return false;
}
if ( new Service<DataView>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, DataView.FriendlyTypeName );
return false;
}
if ( new Service<DataView>( Context ).Queryable().Any( a => a.TransformEntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, DataView.FriendlyTypeName );
return false;
}
if ( new Service<DataViewFilter>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, DataViewFilter.FriendlyTypeName );
return false;
}
if ( new Service<EntitySet>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, EntitySet.FriendlyTypeName );
return false;
}
if ( new Service<FinancialGateway>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, FinancialGateway.FriendlyTypeName );
return false;
}
if ( new Service<FinancialScheduledTransactionDetail>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, FinancialScheduledTransactionDetail.FriendlyTypeName );
return false;
}
if ( new Service<FinancialTransactionDetail>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, FinancialTransactionDetail.FriendlyTypeName );
return false;
}
if ( new Service<FollowingEventType>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, FollowingEventType.FriendlyTypeName );
return false;
}
if ( new Service<FollowingEventType>( Context ).Queryable().Any( a => a.FollowedEntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, FollowingEventType.FriendlyTypeName );
return false;
}
if ( new Service<FollowingSuggestionType>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, FollowingSuggestionType.FriendlyTypeName );
return false;
}
if ( new Service<History>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, History.FriendlyTypeName );
return false;
}
if ( new Service<History>( Context ).Queryable().Any( a => a.RelatedEntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, History.FriendlyTypeName );
return false;
}
if ( new Service<InteractionChannel>( Context ).Queryable().Any( a => a.ComponentEntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, InteractionChannel.FriendlyTypeName );
return false;
}
if ( new Service<InteractionChannel>( Context ).Queryable().Any( a => a.InteractionEntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, InteractionChannel.FriendlyTypeName );
return false;
}
if ( new Service<MergeTemplate>( Context ).Queryable().Any( a => a.MergeTemplateTypeEntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, MergeTemplate.FriendlyTypeName );
return false;
}
if ( new Service<MetricPartition>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, MetricPartition.FriendlyTypeName );
return false;
}
if ( new Service<NoteType>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, NoteType.FriendlyTypeName );
return false;
}
if ( new Service<PersonBadge>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, PersonBadge.FriendlyTypeName );
return false;
}
if ( new Service<Report>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, Report.FriendlyTypeName );
return false;
}
if ( new Service<SignatureDocumentTemplate>( Context ).Queryable().Any( a => a.ProviderEntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, SignatureDocumentTemplate.FriendlyTypeName );
return false;
}
if ( new Service<Tag>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, Tag.FriendlyTypeName );
return false;
}
if ( new Service<UserLogin>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, UserLogin.FriendlyTypeName );
return false;
}
if ( new Service<WorkflowTrigger>( Context ).Queryable().Any( a => a.EntityTypeId == item.Id ) )
{
errorMessage = string.Format( "This {0} is assigned to a {1}.", EntityType.FriendlyTypeName, WorkflowTrigger.FriendlyTypeName );
return false;
}
return true;
}
}
/// <summary>
/// Generated Extension Methods
/// </summary>
public static partial class EntityTypeExtensionMethods
{
/// <summary>
/// Clones this EntityType object to a new EntityType object
/// </summary>
/// <param name="source">The source.</param>
/// <param name="deepCopy">if set to <c>true</c> a deep copy is made. If false, only the basic entity properties are copied.</param>
/// <returns></returns>
public static EntityType Clone( this EntityType source, bool deepCopy )
{
if (deepCopy)
{
return source.Clone() as EntityType;
}
else
{
var target = new EntityType();
target.CopyPropertiesFrom( source );
return target;
}
}
/// <summary>
/// Copies the properties from another EntityType object to this EntityType object
/// </summary>
/// <param name="target">The target.</param>
/// <param name="source">The source.</param>
public static void CopyPropertiesFrom( this EntityType target, EntityType source )
{
target.Id = source.Id;
target.AssemblyName = source.AssemblyName;
target.ForeignGuid = source.ForeignGuid;
target.ForeignKey = source.ForeignKey;
target.FriendlyName = source.FriendlyName;
target.IndexDocumentUrl = source.IndexDocumentUrl;
target.IndexResultTemplate = source.IndexResultTemplate;
target.IsCommon = source.IsCommon;
target.IsEntity = source.IsEntity;
target.IsIndexingEnabled = source.IsIndexingEnabled;
target.IsSecured = source.IsSecured;
target.MultiValueFieldTypeId = source.MultiValueFieldTypeId;
target.Name = source.Name;
target.SingleValueFieldTypeId = source.SingleValueFieldTypeId;
target.Guid = source.Guid;
target.ForeignId = source.ForeignId;
}
}
}