• 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

  • 相关阅读:
    学会倾听,创建良性的交流通道
    服务器监控及其监控工具
    linux环境部署
    科技型中小企业有哪些?
    内网渗透体系学习6
    C++ Reference: Standard C++ Library reference: C Library: cwchar: fwprintf
    2011年09月06日 Go生态洞察:Go语言的反射法则
    《 Python List 列表全实例详解系列(九)》__列表反转(6种方法)
    【21天学习挑战赛】算法——选择排序
    java版工程管理系统Spring Cloud+Spring Boot+Mybatis实现工程管理系统源码
  • 原文地址:https://blog.csdn.net/m0_74456535/article/details/127936339