public List <MasterUserView> FetchAllWithPagination(ref BaseSearchQueryModel searchQuery) { var institutionId = _securityService.GetCurrentInstitutionId(); var result = _masterUserRepository.Query() .Include(u => u.Institutions) .Include(u => u.Institutions.Select(i => i.Institution)) .Where(u => u.IsActive && u.Institutions.Any(i => i.IsActive && i.InstitutionId == institutionId)); searchQuery.TotalData = BaseSearchQueryExpression <MasterUser> .DefaultQueryExpression(ref result, searchQuery); return (result.ToList() .Select( r => new MasterUserView() { UserId = r.UserId, UserName = r.UserName, FullName = r.FullName, DefaultInstitutionId = r.DefaultInstitutionId, Institutions = r.Institutions }) .ToList()); }
public static IQueryable <T> DefaultPaginateQueryable(IQueryable <T> data, BaseSearchQueryModel searchQuery) { var take = searchQuery.DataPerPage; var skip = (searchQuery.Page - 1) * take; return(data.Skip(skip).Take(take)); }
public static IQueryable <T> DefaultSearchQueryable(IQueryable <T> data, BaseSearchQueryModel searchQuery) { var query = ""; if (searchQuery.Search == null) { return(data); } if (String.IsNullOrEmpty(searchQuery.Search.Keyword)) { return(data); } searchQuery.Search.Fields.ToList().ForEach(f => { query = query + String.Format("{0}.ToString().ToLower().Contains(\"{1}\")", f, searchQuery.Search.Keyword.ToLower()); query = query + " || "; }); query = query.Substring(0, query.Length - 4); var searchExpression = query; return(!String.IsNullOrEmpty(searchExpression) ? data.Where(searchExpression) : data); }
public List <TkmTransaction> FetchAllWithPagination(ref BaseSearchQueryModel searchQuery) { var result = _transactionRepository.Query().Where(b => b.IsActive); searchQuery.TotalData = BaseSearchQueryExpression <TkmTransaction> .DefaultQueryExpression(ref result, searchQuery); return(result.OrderByDescending(e => e.TransactionDate).ThenByDescending(e => e.LastUpdatedDate).ToList()); }
public List <MasterInstitution> FetchAllWithPagination(ref BaseSearchQueryModel searchQuery) { var result = _institutionRepository.Query().Where(i => i.IsActive); searchQuery.TotalData = BaseSearchQueryExpression <MasterInstitution> .DefaultQueryExpression(ref result, searchQuery); return(result.ToList()); }
public List <MasterUom> FetchAllWithPagination(ref BaseSearchQueryModel searchQuery) { var result = _uomRepository.Query().Where(u => u.IsActive); searchQuery.TotalData = BaseSearchQueryExpression <MasterUom> .DefaultQueryExpression(ref result, searchQuery); return(result.ToList()); }
public static IQueryable <T> DefaultSortQueryable(IQueryable <T> data, BaseSearchQueryModel searchQuery) { if (!String.IsNullOrEmpty(searchQuery.SortBy)) { return(searchQuery.IsSortAsc ? data.OrderBy(searchQuery.SortBy + " ASC") : data.OrderBy(searchQuery.SortBy + " DESC")); } return(data); }
public List <MasterRole> FetchAllWithPagination(ref BaseSearchQueryModel searchQuery) { var institutionId = _securityService.GetCurrentInstitutionId(); var result = _roleRepository.Query().Where(r => r.IsActive && r.InstitutionId == institutionId); searchQuery.TotalData = BaseSearchQueryExpression <MasterRole> .DefaultQueryExpression(ref result, searchQuery); return(result.ToList()); }
public List <MasterBin> FetchAllWithPagination(ref BaseSearchQueryModel searchQuery) { var institutionId = _securityService.GetCurrentInstitutionId(); var result = _binRepository.Query().Where(b => b.IsActive && b.IsActive && b.InstitutionId == institutionId).Include(b => b.ReaderModule); searchQuery.TotalData = BaseSearchQueryExpression <MasterBin> .DefaultQueryExpression(ref result, searchQuery); return(result.ToList()); }
public static int DefaultQueryExpression(ref IQueryable <T> data, BaseSearchQueryModel searchQuery) { var dataCount = 0; data = DefaultSearchQueryable(data, searchQuery); dataCount = data.Count(); data = DefaultSortQueryable(data, searchQuery); data = DefaultPaginateQueryable(data, searchQuery); return(dataCount); }
public List <MasterItem> FetchAllWithPagination(ref BaseSearchQueryModel searchQuery) { var institutionId = _securityService.GetCurrentInstitutionId(); var result = _itemRepository.Query() .Include(i => i.Uom) .Include(i => i.Brand) .Where(i => i.IsActive && i.InstitutionId == institutionId); searchQuery.TotalData = BaseSearchQueryExpression <MasterItem> .DefaultQueryExpression(ref result, searchQuery); return(result.ToList()); }
public IHttpActionResult FetchAllWithPagination(BaseSearchQueryModel searchQuery) { try { var data = _binService.FetchAllWithPagination(ref searchQuery); return(Ok(new PageResponseInfo() { Data = data.ToList <object>(), TotalData = searchQuery.TotalData })); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public List <MasterUserInstitutionRole> FetchAllWithPagination(ref BaseSearchQueryModel searchQuery, long userId) { var institutionId = _securityService.GetCurrentInstitutionId(); var user = _userService.FetchOne(userId); if (user == null) { return(null); } var userInstitution = user.Institutions.FirstOrDefault(u => u.InstitutionId == institutionId); var result = _userInstitutionRoleRepository.Query() .Where( u => u.IsActive && u.UserInstitutionId == userInstitution.UserInstitutionId && u.InstitutionId == institutionId); searchQuery.TotalData = BaseSearchQueryExpression <MasterUserInstitutionRole> .DefaultQueryExpression(ref result, searchQuery); return(result.ToList()); }