-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserDL.cs
More file actions
81 lines (75 loc) · 3.02 KB
/
UserDL.cs
File metadata and controls
81 lines (75 loc) · 3.02 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
// C# sourcecode
/**********************************************************************************************************************
Author: Param Varun Reddy
Created: 2024-02-28
Description: Repository pattern Data Layer class UserDetails, that was implemented to get the User Details by Id.
Entity has fields to get the user Language. we will be retrieving these fields first, if these fields are Null,
then we will be taking User settings or preferences.
***********************************************************************************************************************/
namespace RexStudios.LanguageDependentNotification
{
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using RexStudios.Extensions;
using RexStudios.LanguageDependentNotification.Core;
using System;
internal class UserDL : EntityRetrieverBase<Entity>, IUserRepo
{
private ITracingService tracingService = null;
public UserDL(IOrganizationService service, ITracingService _tracingService)
: base(service, _tracingService, "systemusers")
{
traceService = _tracingService;
}
/// <summary>
/// Finfd if the user id Exxist
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public override bool Exists(Guid id)
{
return this.Retrieve(id, new ColumnSet(false)) != null;
}
/// <summary>
/// Get All Attributes in an 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 User Details by using Uswer Id
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public Entity GetUserDetailsById(Guid? userId)
{
try
{
if (orgService == null)
throw new InvalidPluginExecutionException($"GetUserDetailsById: Organization service is null, can't process the request");
if (GuidExtensions.IsNullOrEmpty(userId))
throw new InvalidPluginExecutionException($"GetUserDetailsById: Guid is null, can't process the request");
var userDetails = this.Retrieve(userId.Value, new ColumnSet(false));
if(userDetails != null)
{
return userDetails;
}
return null;
}
catch (InvalidPluginExecutionException ex)
{
tracingService?.Trace($"Invalid Exception GetUserDetailsById: {ex.Message}");
throw ex;
}
catch (Exception ex)
{
tracingService?.Trace($"Invalid Exception GetUserDetailsById: {ex.Message}");
throw ex;
}
}
}
}