コード例 #1
0
ファイル: CategoryController.cs プロジェクト: 88886/jnmmes
        public async Task <ActionResult> Query(CategoryQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (CategoryServiceClient client = new CategoryServiceClient())
                {
                    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 <Category> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
コード例 #2
0
 private void LoadItems()
 {
     if (ApplicationData.Category == null)
     {
         return;
     }
     ApplicationData.Category = _catClient.Get(ApplicationData.Category.Id);
     _viewModel.Items         = new ObservableCollection <Item>(ApplicationData.Category.Items.ToList());
 }
コード例 #3
0
ファイル: CategoryController.cs プロジェクト: 88886/jnmmes
        //
        // GET: /EDC/Category/
        public async Task <ActionResult> Index()
        {
            using (CategoryServiceClient client = new CategoryServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key"
                    };
                    MethodReturnResult <IList <Category> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new CategoryQueryViewModel()));
        }
コード例 #4
0
ファイル: PointViewModels.cs プロジェクト: 88886/jnmmes
        public IEnumerable <SelectListItem> GetCategoryList()
        {
            using (CategoryServiceClient client = new CategoryServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("Status='{0}'", Convert.ToInt32(EnumObjectStatus.Available))
                };

                MethodReturnResult <IList <Category> > 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>());
        }
コード例 #5
0
ファイル: CategoryController.cs プロジェクト: 88886/jnmmes
        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 (CategoryServiceClient client = new CategoryServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <Category> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
コード例 #6
0
 // GET: Products/Create
 public ActionResult Create()
 {
     ViewBag.CategoryId = new SelectList(cate.Get(), "Id", "Name");
     return(View());
 }
コード例 #7
0
        public CategoryDto Get(string id)
        {
            CategoryDto category = categoryServiceClient.Get(id);

            return(category);
        }