public async Task <IActionResult> GetByXinAndName() { var xin = Request.Query["xin"].ToString(); var name = Request.Query["name"].ToString(); var id = Request.Query["id"].ToString(); var isPatentAttorney = Request.Query["isPatentAttorney"].ToString(); var powerAttorneyFullNum = Request.Query["powerAttorneyFullNum"].ToString(); var customerTypeId = Request.Query["customerTypeId"].ToString(); var stringQuery = string.Join(";", id, xin, name, isPatentAttorney, powerAttorneyFullNum, customerTypeId); var dicCustomersRequest = GetDicCustomersRequest.ConstructFromQueryStringParameters(stringQuery); var customers = Executor.GetQuery <GetDicCustomersQuery>().Process(q => q.Execute(dicCustomersRequest)); if (customers.Any() == false && dicCustomersRequest.HasXin) { var customer = await _customerUpdater.GetCustomer(dicCustomersRequest.Xin, dicCustomersRequest.IsPatentAttorney); if (customer != null) { customers = Executor.GetQuery <GetDicCustomersQuery>().Process(q => q.Execute(dicCustomersRequest)); } } var result = customers.ProjectTo <SubjectDto>(); var pagedList = result.ToPagedList(Request.GetPaginationParams()); return(pagedList.AsOkObjectResult(Response)); }
public IQueryable <DicCustomer> Execute(GetDicCustomersRequest request) { var customerRepo = Uow.GetRepository <DicCustomer>(); var dicCustomerQuery = customerRepo .AsQueryable() .Include(c => c.Type) .Where(d => d.IsDeleted == false) .Where(IsCustomerPatentAttorney(request.IsPatentAttorney)); if (request.HasXin) { dicCustomerQuery = dicCustomerQuery.Where(IsCustomerXinContains(request.Xin)); } if (request.HasName) { dicCustomerQuery = dicCustomerQuery.Where(IsCustomerNameContains(request.Name)); } if (request.HasRegNumer) { dicCustomerQuery = dicCustomerQuery.Where(IsCustomerPowerAttorneyFullNumContains(request.RegNumber)); } if (request.HasId) { dicCustomerQuery = dicCustomerQuery.Where(IsCustomerIdContains(request.Id)); } if (request.HasCustomerTypeId) { dicCustomerQuery = dicCustomerQuery.Where(IsCustomerTypeContains(request.CustomerTypeId)); } dicCustomerQuery = dicCustomerQuery.Include(c => c.Type); return(dicCustomerQuery); }