/// <summary> /// Prepare paged GDPR request list model /// </summary> /// <param name="searchModel">GDPR request search model</param> /// <returns>GDPR request list model</returns> public virtual GdprLogListModel PrepareGdprLogListModel(GdprLogSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } var customerId = 0; var customerInfo = ""; if (!String.IsNullOrEmpty(searchModel.SearchEmail)) { var customer = _customerService.GetCustomerByEmail(searchModel.SearchEmail); if (customer != null) { customerId = customer.Id; } else { customerInfo = searchModel.SearchEmail; } } //get requests var gdprLog = _gdprService.GetAllLog( customerId: customerId, customerInfo: customerInfo, requestType: searchModel.SearchRequestTypeId > 0 ? (GdprRequestType?)searchModel.SearchRequestTypeId : null, pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize); //prepare list model var model = new GdprLogListModel { Data = gdprLog.Select(log => { //fill in model values from the entity var customer = _customerService.GetCustomerById(log.CustomerId); var requestModel = new GdprLogModel { Id = log.Id, CustomerInfo = customer != null && !customer.Deleted && !String.IsNullOrEmpty(customer.Email) ? customer.Email : log.CustomerInfo, RequestType = _localizationService.GetLocalizedEnum(log.RequestType), RequestDetails = log.RequestDetails, CreatedOn = _dateTimeHelper.ConvertToUserTime(log.CreatedOnUtc, DateTimeKind.Utc) }; return(requestModel); }), Total = gdprLog.TotalCount }; return(model); }
/// <summary> /// Prepare GDPR request (log) search model /// </summary> /// <param name="searchModel">GDPR request search model</param> /// <returns>GDPR request search model</returns> public virtual GdprLogSearchModel PrepareGdprLogSearchModel(GdprLogSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //prepare request types _baseAdminModelFactory.PrepareGdprRequestTypes(searchModel.AvailableRequestTypes); //prepare page parameters searchModel.SetGridPageSize(); return(searchModel); }