public ActionResult GetPreservationAudits([DataSourceRequest] DataSourceRequest request, DateTime?fromDate, DateTime?toDate) { return(ActionResultHelper.TryCatchWithLogger(() => { DataSourceResult result = new DataSourceResult(); CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel; bool sortingDescending = request.Sorts.Any(x => x.Member == "ActivityDate" && x.SortDirection == ListSortDirection.Descending); if (toDate.HasValue) { toDate = toDate.Value.AddDays(1).AddMinutes(-1); } Guid?idPreservationJournalActivity = null; if (request.Filters.Count > 0) { if (request.Filters.First() is FilterDescriptor descriptor && descriptor.Member == "ActivityName") { idPreservationJournalActivity = Guid.Parse(descriptor.Value.ToString()); } } ICollection <PreservationJournaling> audits = _preservationService.GetPreservationJournalings(null, null, fromDate, toDate, idPreservationJournalActivity, customerCompany.CompanyId, (request.Page - 1) * request.PageSize, request.PageSize, out int journalingsInArchive, false, sortingDescending); result.Total = journalingsInArchive; result.Data = audits.Select(s => new PreservationAuditGridViewModel() { ActivityDate = s.DateActivity, ActivityName = s.PreservationJournalingActivity?.Description, ActivityUser = string.Concat(s.User?.Name, " ", s.User.Surname), Description = string.IsNullOrEmpty(s.Notes) && s.Preservation != null ? s.Preservation.Label : s.Notes, IdPreservation = s.IdPreservation }); return Json(result, JsonRequestBehavior.AllowGet); }, _loggerService)); }