-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotificationTypeDL.cs
More file actions
101 lines (95 loc) · 4.03 KB
/
NotificationTypeDL.cs
File metadata and controls
101 lines (95 loc) · 4.03 KB
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
namespace RexStudios.LanguageDependentNotification
{
using System;
using System.Linq;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using RexStudios.Extensions;
using RexStudios.LanguageDependentNotification.Core;
internal class NotificationTypeDL : EntityRetrieverBase<Entity>, INotificationTypeRepo
{
private ITracingService tracingService = null;
public NotificationTypeDL(IOrganizationService service, ITracingService _tracingService)
: base(service, _tracingService, "rex_notificationtype")
{
tracingService = _tracingService;
}
public override bool Exists(Guid id)
{
return this.Retrieve(id, new ColumnSet(false)) != null;
}
/// <summary>
/// Gets the usersettings entity by Guid
/// </summary>
/// <param name="entityId"></param>
/// <param name="columnSet"></param>
/// <returns></returns>
public override Entity Retrieve(Guid entityId, ColumnSet columnSet)
{
return base.Retrieve(entityId, columnSet);
}
/// <summary>
/// Get NotificationType by Text
/// </summary>
/// <param name="NotificationTypeText"></param>
/// <returns> returns notification type Entity</returns>
public Entity GetNotificationTypeByText(string NotificationTypeText)
{
try
{
if (orgService == null)
throw new InvalidPluginExecutionException($"GetNotificationTypeByText: Organization service is null, can't process the request");
if (StringExtensions.IsNullOrEmpty(NotificationTypeText))
throw new InvalidPluginExecutionException($"GetNotificationTypeByText: NotificationType is null, can't process the request");
QueryExpression query = new QueryExpression(base.EntityLogicalName)
{
ColumnSet = new ColumnSet(true),
Criteria = new FilterExpression()
{
Conditions = {
new ConditionExpression()
{
AttributeName = "name",
Operator = ConditionOperator.Equal,
Values = { NotificationTypeText }
}
}
}
};
tracingService?.Trace($"1--> GetNotificationTypeByText: Query expression is completed ");
return base.RetrieveMultipleEntities(query).FirstOrDefault();
}
catch (InvalidPluginExecutionException ex)
{
tracingService?.Trace($"Invalid Exception GetNotificationTypeByText: {ex.Message}");
throw ex;
}
catch (Exception ex)
{
tracingService?.Trace($"Invalid Exception GetNotificationTypeByText: {ex.Message}");
throw ex;
}
}
public Entity GetNotificationTypeById(Guid? NotificationTypeId)
{
try
{
if (orgService == null)
throw new InvalidPluginExecutionException($"GetNotificationTypeById: Organization service is null, can't process the request");
if (GuidExtensions.IsNullOrEmpty(NotificationTypeId))
throw new InvalidPluginExecutionException($"GetNotificationTypeById: NotificationTypeId is null or empty, can't process the request");
return this.Retrieve(NotificationTypeId.Value, new ColumnSet(true));
}
catch (InvalidPluginExecutionException ex)
{
tracingService?.Trace($"Invalid Exception GetNotificationTypeById: {ex.Message}");
throw ex;
}
catch (Exception ex)
{
tracingService?.Trace($"Invalid Exception GetNotificationTypeById: {ex.Message}");
throw ex;
}
}
}
}