Exemplo n.º 1
0
        public async Task <ActionResult> Query(DecayQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (DecayServiceClient client = new DecayServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.Code))
                            {
                                where.AppendFormat(" {0} Key.Code LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Code);
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <Decay> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Exemplo n.º 2
0
        public ActionResult GetDecayCode(string q)
        {
            IList <Decay> lstDetail = new List <Decay>();

            using (DecayServiceClient client = new DecayServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format(@"Key.Code LIKE '{0}%'
                                            AND IsUsed=1"
                                             , q),
                    OrderBy = "Key.Code"
                };

                MethodReturnResult <IList <Decay> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null)
                {
                    lstDetail = result.Data;
                }
            }

            var lnq = from item in lstDetail
                      select item.Key.Code;

            return(Json(from item in lnq.Distinct()
                        select new
            {
                @label = item,
                @value = item,
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        //
        // GET: /ZPVM/Decay/
        public async Task <ActionResult> Index()
        {
            using (DecayServiceClient client = new DecayServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key"
                    };
                    MethodReturnResult <IList <Decay> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new DecayQueryViewModel()));
        }
Exemplo n.º 4
0
        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 (DecayServiceClient client = new DecayServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <Decay> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }