public ActionResult GetMaxItemNo(string categoryName) { using (CategoryDetailServiceClient client = new CategoryDetailServiceClient()) { PagingConfig cfg = new PagingConfig() { PageNo = 0, PageSize = 1, Where = string.Format("Key.CategoryName='{0}'", categoryName), OrderBy = "ItemNo Desc" }; MethodReturnResult <IList <CategoryDetail> > result = client.Get(ref cfg); if (result.Code <= 0 && result.Data != null && result.Data.Count > 0) { return(Json(result.Data[0].ItemNo + 1, JsonRequestBehavior.AllowGet)); } } return(Json(1, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> Query(CategoryDetailQueryViewModel model) { if (ModelState.IsValid) { using (CategoryDetailServiceClient client = new CategoryDetailServiceClient()) { await Task.Run(() => { StringBuilder where = new StringBuilder(); if (model != null) { where.AppendFormat(" {0} Key.CategoryName = '{1}'" , where.Length > 0 ? "AND" : string.Empty , model.CategoryName); if (!string.IsNullOrEmpty(model.ParameterName)) { where.AppendFormat(" {0} Key.ParameterName LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.ParameterName); } } PagingConfig cfg = new PagingConfig() { OrderBy = "ItemNo", Where = where.ToString() }; MethodReturnResult <IList <CategoryDetail> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }
// // GET: /EDC/CategoryDetail/ public async Task <ActionResult> Index(string categoryName) { using (CategoryServiceClient client = new CategoryServiceClient()) { MethodReturnResult <Category> result = await client.GetAsync(categoryName ?? string.Empty); if (result.Code > 0 || result.Data == null) { return(RedirectToAction("Index", "Category")); } ViewBag.Category = result.Data; } using (CategoryDetailServiceClient client = new CategoryDetailServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { OrderBy = "ItemNo", Where = string.Format(" Key.CategoryName = '{0}'" , categoryName) }; MethodReturnResult <IList <CategoryDetail> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } return(View(new CategoryDetailQueryViewModel() { CategoryName = categoryName })); }
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 (CategoryDetailServiceClient client = new CategoryDetailServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { PageNo = pageNo, PageSize = pageSize, Where = where ?? string.Empty, OrderBy = orderBy ?? string.Empty }; MethodReturnResult <IList <CategoryDetail> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }