示例#1
0
        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);
        }
示例#2
0
        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));
        }
示例#3
0
 public IActionResult List([FromBody] GlobalFilteredPaginationIncomeModel model)
 {
     return(OkResult(_nRelationTypeService.GetList(model, CurrentUser.CompanyId)));
 }