public IQueryable <RelationType> GetList(GlobalFilteredPaginationIncomeModel model, Guid?companyId) { var filter = ParseFilter(model.Filter); Expression <Func <RelationType, bool> > condition = w => (w.CreatedByCompanyId == companyId || _dbContext.Companies.Where(c => c.CreatedByCompanyId == companyId).Select(cc => cc.Id) .Contains(w.CreatedByCompanyId)) && (filter.Name == string.Empty || w.Name.Contains(filter.Name)); var nRelationTypes = _dbContext.NRelationTypes .Where(condition) .OrderByDescending(o => o.CreatedDate); return(nRelationTypes); }
public PaginatedListViewModel <NRelationTypeViewModel> GetList(GlobalFilteredPaginationIncomeModel model, Guid?companyId) { var nRelationTypes = _nRelationTypeRepository.GetList(model, companyId).Select(nr => new NRelationTypeViewModel { Id = nr.Id, Name = nr.Name, IsDeletable = !nr.Companies.Any(), CreatedDate = nr.CreatedDate, CreatedBy = $"{nr.CreatedBy.FirstName} {nr.CreatedBy.LastName}", CreatedById = nr.CreatedById, }); return(_nRelationTypeRepository.Pagination(nRelationTypes, model)); }
public IActionResult List([FromBody] GlobalFilteredPaginationIncomeModel model) { return(OkResult(_nRelationTypeService.GetList(model, CurrentUser.CompanyId))); }