Created
September 11, 2020 21:39
-
-
Save rofr/c0dfe07da575453492bdeaf78ad894ec to your computer and use it in GitHub Desktop.
How is your day going?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Expression<Func<ActivityHistory, bool>> GetSearchActivityExpression(ActivityHistorySearchParameters searchParameters, ActivityHistorySearchIdLists idLists) | |
{ | |
return x => ((!searchParameters.DateFrom.HasValue || (DbFunctions.TruncateTime(x.CreatedDate) >= DbFunctions.TruncateTime(searchParameters.DateFrom.Value))) | |
&& (!searchParameters.DateTo.HasValue || (DbFunctions.TruncateTime(x.CreatedDate) <= DbFunctions.TruncateTime(searchParameters.DateTo.Value)))) && | |
((searchParameters.ActionByCustomerId.HasValue && x.ActionByCustomerId.HasValue && searchParameters.ActionByCustomerId.Value == x.ActionByCustomerId.Value) || !searchParameters.ActionByCustomerId.HasValue) && // SystemAdmin are the only one without a CustomerId, they can see everything | |
((searchParameters.ActionByDepartmentId.HasValue && x.ActionByDepartmentId.HasValue && searchParameters.ActionByDepartmentId.Value == x.ActionByDepartmentId.Value) || !searchParameters.ActionByDepartmentId.HasValue) && | |
(!searchParameters.ActionType.HasValue || x.ActionType == searchParameters.ActionType) && | |
(!searchParameters.ActionSubType.HasValue || x.ActionSubType == searchParameters.ActionSubType) && | |
(searchParameters.ActionByName == null || searchParameters.ActionByName == "" || | |
x.ActionByType == ActivityHistoryObjectType.User && idLists.UserByList.Contains(x.ActionById) || | |
x.ActionByType == ActivityHistoryObjectType.Carrier && idLists.CarrierByList.Contains(x.ActionById)) && | |
(searchParameters.ActionOnName == null || searchParameters.ActionOnName == "" || | |
(x.ActionOnId.HasValue && x.ActionOnType.HasValue && | |
((idLists.UserOnList.Contains(x.ActionOnId.Value) && x.ActionOnType.Value == ActivityHistoryObjectType.User) || | |
(idLists.CarrierOnList.Contains(x.ActionOnId.Value) && x.ActionOnType.Value == ActivityHistoryObjectType.Carrier) || | |
(idLists.DepartmentOnList.Contains(x.ActionOnId.Value) && x.ActionOnType.Value == ActivityHistoryObjectType.Department) || | |
(idLists.DeviceOnList.Contains(x.ActionOnId.Value) && x.ActionOnType.Value == ActivityHistoryObjectType.Device)))) && | |
(x.ActionById != 0 && x.ActionOnId != 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment