/// <summary> /// Gets the document and form search. /// </summary> /// <param name="documentAndFormFilterBO">The document and form filter bo.</param> /// <param name="auditLogBO">The audit log bo.</param> /// <returns></returns> /// <exception cref="CustomException"> /// MemberDocumentSearchFilterEmptyErrorCode /// or /// MemberDocumentSearchResultEmptyErrorCode /// </exception> public async Task <IEnumerable <DocumentAndFormBO> > GetDocumentAndFormSearch(DocumentAndFormFilterBO documentAndFormFilterBO, AuditLogBO auditLogBO) { if (documentAndFormFilterBO == null) { throw new CustomException(nameof(MemberConstants.MemberDocumentSearchFilterEmptyErrorCode)); } var response = await _memberDocumentAndFormDa.GetDocumentAndFormSearch(documentAndFormFilterBO, auditLogBO); if (response == null) { throw new CustomException(nameof(MemberConstants.MemberDocumentSearchResultEmptyErrorCode)); } return(response); }
/// <summary> /// Gets the document and form search. /// </summary> /// <param name="documentAndFormFilterBO">The document and form filter bo.</param> /// <param name="auditLogBO">The audit log bo.</param> /// <returns></returns> /// <exception cref="System.Exception"></exception> public async Task <IEnumerable <DocumentAndFormBO> > GetDocumentAndFormSearch(DocumentAndFormFilterBO documentAndFormFilterBO, AuditLogBO auditLogBO) { var documentAndFormBOs = MemberMapper.Map(await GetDocumentAndForms()); documentAndFormFilterBO.SearchText = string.IsNullOrEmpty(documentAndFormFilterBO.SearchText) ? string.Empty : documentAndFormFilterBO.SearchText; documentAndFormBOs = documentAndFormBOs.Where(x => x.DocumentName.Trim().ToLower().Contains(documentAndFormFilterBO.SearchText.ToLower())).ToList(); switch (documentAndFormFilterBO.SortColumn.ToLower()) { case BrokerConstants.FILE_NAME: documentAndFormBOs = documentAndFormFilterBO.IsSortByDesc ? documentAndFormBOs.OrderByDescending(x => x.DocumentName).ThenByDescending(x => x.LastUpdatedOn).ToList() : documentAndFormBOs.OrderBy(x => x.DocumentName).ThenByDescending(x => x.LastUpdatedOn).ToList(); break; case BrokerConstants.CATEGORY_LOWER: documentAndFormBOs = documentAndFormFilterBO.IsSortByDesc ? documentAndFormBOs.OrderByDescending(x => x.CategoryName).ThenByDescending(x => x.LastUpdatedOn).ToList() : documentAndFormBOs.OrderBy(x => x.CategoryName).ThenByDescending(x => x.LastUpdatedOn).ToList(); break; case BrokerConstants.LAST_UPDATED_ON: documentAndFormBOs = documentAndFormFilterBO.IsSortByDesc ? documentAndFormBOs.OrderByDescending(x => x.LastUpdatedOn).ToList() : documentAndFormBOs.OrderBy(x => x.LastUpdatedOn).ToList(); break; default: documentAndFormBOs = documentAndFormBOs.OrderByDescending(a => a.LastUpdatedOn).ToList(); break; } if (documentAndFormFilterBO.RecordsPerPage > 0) { var pageStartCount = (documentAndFormFilterBO.PageNumber - 1) * documentAndFormFilterBO.RecordsPerPage; documentAndFormBOs = documentAndFormBOs.Skip(pageStartCount).Take(documentAndFormFilterBO.RecordsPerPage).ToList(); } //await AuditMapper.AuditLogging(auditLogBO, null, AuditAction.Select, null); return(documentAndFormBOs); }