示例#1
0
        public async Task <NotesSearchResultDTO> SearchAsync(int entityId, string searchedString, int?categoryId,
                                                             DateTime?exactDate, DateTime?fromDate, DateTime?toDate, string creator, NotesSearchByStatus searchByStatus, string sortOption, bool sortIsAscending, int?skip, int?take)
        {
            if (fromDate != null && toDate != null)
            {
                if (fromDate > toDate)
                {
                    throw new ApplicationException("From date should be greater than to date.");
                }
            }

            return(new NotesSearchResultDTO
            {
                NotesCount = await _repository.CountAsync(entityId, searchedString, categoryId, exactDate, fromDate, toDate, creator, searchByStatus),
                Notes = (await _repository.SearchAsync(entityId, searchedString, categoryId, exactDate, fromDate, toDate, creator, searchByStatus, sortOption, sortIsAscending, skip, take))
                        .Select(note => ConvertToNoteDTO(note))
                        .ToList()
            });
        }