public async Task <JsonResult> GetAsync([FromQuery] DepartmentQueryDto condition, int?pageIndex, int?pageSize) { if (pageIndex == null || pageSize == null) { if (condition.DepartmentCode != null || condition.Address != null || condition.ContactPhone != null || condition.DepartmentCode != null || condition.DepartmentName != null || condition.Email != null || condition.Fax != null || condition.Notes != null || condition.PrincipalName != null) { var list = _service.Search(condition); return(new JsonResult(new { code = 20000, list })); } var items = await _service.GetAll(); return(new JsonResult(new { code = 20000, items })); } else { var items = await _service.GetPaginationAsync(pageIndex.Value, pageSize.Value); return(new JsonResult(new { code = 20000, items })); } }
public List <Department> Get(DepartmentQueryDto condition) { IQueryable <Department> query = _repository.Query(); if (condition.DepartmentName != null && condition.DepartmentName.Trim() != "") { query = query.Where(Department => Department.DepartmentName.Contains(condition.DepartmentName)); } if (condition.Address != null && condition.Address.Trim() != "") { query = query.Where(Department => Department.Address.Contains(condition.Address)); } if (condition.DepartmentCode != null && condition.DepartmentCode.Trim() != "") { query = query.Where(Department => Department.DepartmentCode.Contains(condition.DepartmentCode)); } if (condition.Email != null && condition.Email.Trim() != "") { query = query.Where(Department => Department.Email.Contains(condition.Email)); } if (condition.Fax != null && condition.Fax.Trim() != "") { query = query.Where(Department => Department.Fax.Contains(condition.Fax)); } if (condition.ContactPhone != null && condition.ContactPhone.Trim() != "") { query = query.Where(Department => Department.ContactPhone.Contains(condition.ContactPhone)); } if (condition.PrincipalName != null && condition.PrincipalName.Trim() != "") { query = query.Where(Department => Department.PrincipalName.Contains(condition.PrincipalName)); } if (condition.Notes != null && condition.Notes.Trim() != "") { query = query.Where(Department => Department.Notes.Contains(condition.Notes)); } return(query.ToList()); }
public List <Department> Search(DepartmentQueryDto condition) { return(_domain.Get(condition)); }