-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLanguageCodeDL.cs
More file actions
158 lines (152 loc) · 6.13 KB
/
LanguageCodeDL.cs
File metadata and controls
158 lines (152 loc) · 6.13 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
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
// C# sourcecode
/**********************************************************************************************************************
Author: Param Varun Reddy
Created: 2024-02-28
Description: Repository pattern Data Layer class LanguageCode,
***********************************************************************************************************************/
namespace RexStudios.LanguageDependentNotification
{
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using RexStudios.Extensions;
using RexStudios.LanguageDependentNotification.Core;
using System;
using System.Linq;
internal class LanguageCodeDL : EntityRetrieverBase<Entity>, ILanguageCodeRepo
{
private ITracingService tracingService;
public LanguageCodeDL(IOrganizationService service, ITracingService _tracingService)
: base(service, _tracingService, "rex_languagecode")
{
traceService = _tracingService;
}
/// <summary>
/// Check if Entity Exist
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public override bool Exists(Guid id)
{
return this.Retrieve(id, new ColumnSet(false)) != null;
}
/// <summary>
/// Retrieve Entity by ID
/// </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 Language by Id
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Entity GetLanguageByID(Guid? Id)
{
try
{
if (orgService == null)
throw new InvalidPluginExecutionException($"GetLanguageByID: Organization service is null, can't process the request");
if (GuidExtensions.IsNullOrEmpty(Id))
throw new InvalidPluginExecutionException($"GetLanguageByID: Guid is null, can't process the request");
return this.Retrieve(Id.Value, new ColumnSet(true));
}
catch (InvalidPluginExecutionException ex)
{
tracingService?.Trace($"Invalid Exception GetLanguageByID: {ex.Message}");
throw ex;
}
catch (Exception ex)
{
tracingService?.Trace($"Invalid Exception GetLanguageByID: {ex.Message}");
throw ex;
}
}
// <summary>
// Get Language Entity By Language Code
// </summary>
// <param name="languageCode"></param>
// <returns>Language Entity</returns>
public Entity GetLanguageByLanguageCode(int? languageCode)
{
try
{
if (orgService == null)
throw new InvalidPluginExecutionException($"GetLanguageByLanguageCode: Organization service is null, can't process the request");
if (languageCode== null || languageCode==0)
throw new InvalidPluginExecutionException($"GetLanguageByLanguageCode: languagecode is null, can't process the request");
QueryExpression query = new QueryExpression(base.EntityLogicalName)
{
ColumnSet = new ColumnSet(true),
Criteria = new FilterExpression()
{
Conditions = {
new ConditionExpression()
{
AttributeName = "rex_language",
Operator = ConditionOperator.Equal,
Values = {languageCode}
}
}
}
};
return base.RetrieveMultipleEntities(query).FirstOrDefault();
}
catch (InvalidPluginExecutionException ex)
{
tracingService?.Trace($"Invalid Exception GetLanguageByLanguageCode: {ex.Message}");
throw ex;
}
catch (Exception ex)
{
tracingService?.Trace($"Invalid Exception GetLanguageByLanguageCode: {ex.Message}");
throw ex;
}
}
/// <summary>
/// Get Lanaguage by langaugeCode
/// </summary>
/// <param name="culture"></param>
/// <returns></returns>
public Entity GeyLanguagebyCulture(string culture)
{
try
{
if (orgService == null)
throw new InvalidPluginExecutionException($"GetLanguageByID: Organization service is null, can't process the request");
if (StringExtensions.IsNullOrEmpty(culture))
throw new InvalidPluginExecutionException($"GetLanguageByID: Guid is null, can't process the request");
QueryExpression query = new QueryExpression(base.EntityLogicalName)
{
ColumnSet = new ColumnSet(true),
Criteria = new FilterExpression()
{
Conditions = {
new ConditionExpression()
{
AttributeName = "rex_culturenet",
Operator = ConditionOperator.Equal,
Values = {culture}
}
}
}
};
return base.RetrieveMultipleEntities(query).FirstOrDefault();
}
catch (InvalidPluginExecutionException ex)
{
tracingService?.Trace($"Invalid Exception GeyLanguagebyCulture: {ex.Message}");
throw ex;
}
catch (Exception ex)
{
tracingService?.Trace($"Invalid Exception GeyLanguagebyCulture: {ex.Message}");
throw ex;
}
}
}
}