• MVC第三波书店图书类型获取和实现下拉框功能


     #region 图书类型
            public ActionResult CategryTreePartial()
            {
                Uri uri = new Uri(path);
                HttpClient httpClient = new HttpClient();
                httpClient.BaseAddress = uri;
                var pashAction = httpClient.GetAsync("api/Category");
                var pashResult = pashAction.Result;
                if (pashResult.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var result = pashResult.Content.ReadAsStringAsync().Result;
                    var list = JsonConvert.DeserializeObject>(result);
                    httpClient.Dispose();
                    ViewBag.categryList = list;
                    return PartialView("CategryTreePartial",list);
                }
                else
                {
                    return Content("获取代码错误:" + pashResult.StatusCode);
                }
                

            }
            #endregion
            #region 图书类型实现下拉框功能
            public ActionResult CListPritial()
            {
                //List clist = entity.Categories.ToList();
                Uri uri = new Uri(path);
                HttpClient httpClient = new HttpClient();
                httpClient.BaseAddress = uri;
                var pashAction = httpClient.GetAsync("api/Category");
                var pashResult = pashAction.Result;
                if (pashResult.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var result = pashResult.Content.ReadAsStringAsync().Result;
                    var list = JsonConvert.DeserializeObject>(result);
                    SelectList slist = new SelectList(list, "Id", "Name");
                    ViewBag.categoryList = slist;
                    httpClient.Dispose();
                    return PartialView("CListPritial", slist);
                }
                else
                {
                    return Content("获取代码错误:" + pashResult.StatusCode);
                }
              
            }
            #endregion

     #region 图书类型
            public ActionResult CategryTreePartial()
            {
                Uri uri = new Uri(path);
                HttpClient httpClient = new HttpClient();
                httpClient.BaseAddress = uri;
                var pashAction = httpClient.GetAsync("api/Category");
                var pashResult = pashAction.Result;
                if (pashResult.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var result = pashResult.Content.ReadAsStringAsync().Result;
                    var list = JsonConvert.DeserializeObject>(result);
                    httpClient.Dispose();
                    ViewBag.categryList = list;
                    return PartialView("CategryTreePartial",list);
                }
                else
                {
                    return Content("获取代码错误:" + pashResult.StatusCode);
                }
                

            }
            #endregion
            #region 图书类型实现下拉框功能
            public ActionResult CListPritial()
            {
                //List clist = entity.Categories.ToList();
                Uri uri = new Uri(path);
                HttpClient httpClient = new HttpClient();
                httpClient.BaseAddress = uri;
                var pashAction = httpClient.GetAsync("api/Category");
                var pashResult = pashAction.Result;
                if (pashResult.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var result = pashResult.Content.ReadAsStringAsync().Result;
                    var list = JsonConvert.DeserializeObject>(result);
                    SelectList slist = new SelectList(list, "Id", "Name");
                    ViewBag.categoryList = slist;
                    httpClient.Dispose();
                    return PartialView("CListPritial", slist);
                }
                else
                {
                    return Content("获取代码错误:" + pashResult.StatusCode);
                }
              
            }
            #endregion

  • 相关阅读:
    便捷在线导入:完整Axure元件库集合,让你的设计更高效!
    LeetCode-201. 数字范围按位与-Java-medium
    Java 哈希表
    设计链表复习
    angular:html2canvas报错提示Unable to find iframe window
    statsD学习笔记
    Android原生插件开发-开发篇
    Windows-Oracle11g 安装详解-含Navicate远程连接配置 -本地监听设置及更换navicate环境指向的oci.dll
    centos7安装python3环境
    vue项目分环境打包的具体步骤 --- 区分测试环境与线上环境的打包引用路径
  • 原文地址:https://blog.csdn.net/m0_74456535/article/details/127936339