public async Task <ActionResult> MaterialQuery(ProductControlObjectQueryViewModel model) { //if (ModelState.IsValid) //{ // using (MaterialServiceClient client = new MaterialServiceClient()) // { // await Task.Run(() => // { // StringBuilder where = new StringBuilder(); // where.Append("Key like '12%'"); // if (model != null) // { // if (!string.IsNullOrEmpty(model.ProductCode)) // { // where.AppendFormat(" {0} Key LIKE '{1}%'" // , where.Length > 0 ? "AND" : string.Empty // , model.ProductCode); // } // if (!string.IsNullOrEmpty(model.ProductName)) // { // where.AppendFormat(" {0} Name LIKE '{1}%'" // , where.Length > 0 ? "AND" : string.Empty // , model.ProductName); // } // } // PagingConfig cfg = new PagingConfig() // { // OrderBy = "Key", // Where = where.ToString() // }; // MethodReturnResult<IList<Material>> result = client.Get(ref cfg); // if (result.Code == 0) // { // ViewBag.PagingConfig = cfg; // ViewBag.List = result.Data; // } // }); // } //} return(PartialView("_MaterialListPartial")); }
public string GetQueryCondition(ProductControlObjectQueryViewModel model) { StringBuilder where = new StringBuilder(); if (model != null) { if (!string.IsNullOrEmpty(model.CellEff)) { where.AppendFormat(" {0} Key.CellEff = '{1}'" , where.Length > 0 ? "AND" : string.Empty , model.CellEff); } if (!string.IsNullOrEmpty(model.ProductCode)) { where.AppendFormat(" {0} Key.ProductCode = '{1}'" , where.Length > 0 ? "AND" : string.Empty , model.ProductCode); } if (!string.IsNullOrEmpty(model.SupplierCode)) { where.AppendFormat(" {0} Key.SupplierCode = '{1}'" , where.Length > 0 ? "AND" : string.Empty , model.SupplierCode); } if (!string.IsNullOrEmpty(model.SupplierName)) { where.AppendFormat(" {0} SupplierName LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.SupplierName); } if (!string.IsNullOrEmpty(model.ProductName)) { where.AppendFormat(" {0} ProductName LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.ProductName); } } return(where.ToString()); }