/// <summary>
 /// Get Document Groups
 /// </summary>
 public Models.DocumentGroupSearchRequestResponse Get([FromUri] DocumentGroupSearchRequest request)
 {
     if (request == null || !ModelState.IsValid)
     {
         throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
     }
     return(documentGroupService.SearchDocumentGroup(request).CreateFrom());
 }
Example #2
0
        /// <summary>
        /// Search Document Group
        /// </summary>
        public DocumentGroupSearchRequestResponse SearchDocumentGroup(DocumentGroupSearchRequest request)
        {
            int rowCount;

            return(new DocumentGroupSearchRequestResponse
            {
                DocumentGroups = documentGroupRepository.SearchDocumentGroup(request, out rowCount),
                TotalCount = rowCount
            });
        }
Example #3
0
        /// <summary>
        /// Search Document Group
        /// </summary>
        public IEnumerable <DocumentGroup> SearchDocumentGroup(DocumentGroupSearchRequest request, out int rowCount)
        {
            int fromRow = (request.PageNo - 1) * request.PageSize;
            int toRow   = request.PageSize;
            Expression <Func <DocumentGroup, bool> > query =
                documentGroup =>
                (string.IsNullOrEmpty(request.DocumentGroupFilterText) ||
                 (documentGroup.DocumentGroupName.Contains(request.DocumentGroupFilterText)) ||
                 (documentGroup.DocumentGroupCode.Contains(request.DocumentGroupFilterText)));

            rowCount = DbSet.Count(query);
            return(request.IsAsc
                ? DbSet.Where(query)
                   .OrderBy(documentGroupOrderByClause[request.DocumentGroupOrderBy])
                   .Skip(fromRow)
                   .Take(toRow)
                   .ToList()
                : DbSet.Where(query)
                   .OrderByDescending(documentGroupOrderByClause[request.DocumentGroupOrderBy])
                   .Skip(fromRow)
                   .Take(toRow)
                   .ToList());
        }