Пример #1
0
        public async Task <ActionResult> List(PaginationInfo pagination, TestMasterInfo.Conditions conditions, string view = "")
        {
            #region 取資料

            //var biz = new rita.Business.TestBiz.Master();
            //DataTable dt = biz.Load(ref pagination, conditions: conditions);

            var request = new ApiReruest
            {
                pagination = pagination,
                conditions = conditions
            };

            var biz      = new ApiBiz();
            var response = await biz.Post <ApiResponse>("http://localhost/api/api/", "test", "load", request);

            #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"),
            //        UpdateTime = i.Field<DateTime>("UpdateTime")
            //    })
            //    .ToList();
            //}
            #endregion

            #endregion
            #region ViewBag

            ViewBag.Pager      = response.pagination;
            ViewBag.Conditions = response.conditions;

            #endregion

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

            //return View(model);
            return(PartialView(path, response.data));
        }
Пример #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));
            }
        }