public async Task <ActionResult> Query(EquipmentGroupQueryViewModel model) { if (ModelState.IsValid) { using (EquipmentGroupServiceClient client = new EquipmentGroupServiceClient()) { await Task.Run(() => { StringBuilder where = new StringBuilder(); if (model != null) { if (!string.IsNullOrEmpty(model.Name)) { where.AppendFormat(" {0} Key LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.Name); } } PagingConfig cfg = new PagingConfig() { OrderBy = "Key", Where = where.ToString() }; MethodReturnResult <IList <EquipmentGroup> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }
// // GET: /FMM/EquipmentGroup/ public async Task <ActionResult> Index() { using (EquipmentGroupServiceClient client = new EquipmentGroupServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { OrderBy = "Key" }; MethodReturnResult <IList <EquipmentGroup> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } return(View(new EquipmentGroupQueryViewModel())); }
public IEnumerable <SelectListItem> GetEquipmentGroupList() { using (EquipmentGroupServiceClient client = new EquipmentGroupServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false }; MethodReturnResult <IList <EquipmentGroup> > result = client.Get(ref cfg); if (result.Code <= 0) { return(from item in result.Data select new SelectListItem() { Text = item.Key, Value = item.Key }); } } return(new List <SelectListItem>()); }
public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize) { if (ModelState.IsValid) { int pageNo = currentPageNo ?? 0; int pageSize = currentPageSize ?? 20; if (Request["PageNo"] != null) { pageNo = Convert.ToInt32(Request["PageNo"]); } if (Request["PageSize"] != null) { pageSize = Convert.ToInt32(Request["PageSize"]); } using (EquipmentGroupServiceClient client = new EquipmentGroupServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { PageNo = pageNo, PageSize = pageSize, Where = where ?? string.Empty, OrderBy = orderBy ?? string.Empty }; MethodReturnResult <IList <EquipmentGroup> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }