Beispiel #1
0
        public ActionResult Read(Condtions condtions)
        {
            var biz   = new teresa.business.TestBiz.Master();
            var model = biz.Load(SID: condtions.SID, ID: condtions.ID, NO: condtions.NO);

            //return View(model);
            return(PartialView("~/Views/Shared/Test/_Read.cshtml", model));
        }
Beispiel #2
0
        public async Task <ActionResult> List(PageInationInfo pagination, Condtions condtions, string view = "")
        {
            #region Pager

            //if (pagination == null) pagination = new PageInationInfo();
            //if (pager.HasValue) pagination.Index = pager.Value;
            //pagination.Index = Index;
            //pagination.Size = Size;
            //pagination.Total = Total;
            //int lastPage = pagination.Total / pagination.Size;
            //if ((pagination.Total % pagination.Size) != 0) lastPage += 1;
            //if (pager == "first") pagination.Index = 1;
            //if (pager == "prev" && pagination.Index > 1) pagination.Index -= 1;
            //if (pager == "next" && ((pagination.Index + 1) <= lastPage)) pagination.Index += 1;
            //if (pager == "last") pagination.Index = lastPage;
            //if (!string.IsNullOrEmpty(pager) && pager.StartsWith("page"))
            //{
            //    pagination.Index = Convert.ToInt32(pager.Replace("page", ""));
            //}

            #endregion
            {
                #region 取資料

                //var biz = new teresa.business.TestBiz.Master();
                var request = new ApiRequest
                {
                    pagination = pagination,
                    condtions  = condtions
                };
                var biz      = new ApiBiz();
                var response = await biz.Post <ApiResponse>("http://localhost/API/api/", "test", "load", request);

                //DataTable dt = biz.Load(ref pagination, Condtions: condtions);

                #region 註解
                //Linq
                //List<TestMasterInfo> model = new List<TestMasterInfo>();
                //if (dt != null && dt.Rows.Count > 0)
                //{
                //    model =
                //    dt.AsEnumerable()
                //    .Select(i => new TestMasterInfo
                //    {
                //        SID = i.Field<int>("SID"),
                //        ID = i.Field<string>("ID"),
                //        NO = i.Field<string>("NO"),
                //        Name = i.Field<string>("Name"),
                //        Address = i.Field<string>("Address"),
                //        Phone = i.Field<string>("Phone"),
                //        Age = i.Field<decimal?>("Age"),
                //        Birthday = i.Field<DateTime?>("Birthday"),
                //        CreateTime = i.Field<DateTime>("CreateTime"),
                //        UpdaueTime = i.Field<DateTime>("UpdaueTime")
                //    })
                //    .ToList();
                //}
                #endregion
                #endregion 註解尾

                #region ViewBag
                //ViewBag.Index = pagination.Index;
                //ViewBag.Size = pagination.Size;
                //ViewBag.Total = pagination.Total;
                //ViewBag.ConditonName = condtions.Name;
                ViewBag.condtions = response.condtions;
                ViewBag.Pager     = response.pagination;
                #endregion

                //return View(model);

                string path = "~/Views/Shared/Test/_List.cshtml";
                if (!string.IsNullOrEmpty(view))
                {
                    path = $"~/Views/Shared/Test/_List_{view}.cshtml";
                }

                return(PartialView(path, response.data));
            }
        }