#region 图书详情
public ActionResult Detail(string ticket,int? id)
{
Uri uri = new Uri(path);
HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = uri;
HttpContent context = new StringContent(ticket);
context.Headers.Add("Authorization", "BasicAuth" + ticket);
var pashAction = httpClient.GetAsync("api/Book/id="+id);
var pashResult = pashAction.Result;
if (pashResult.StatusCode == System.Net.HttpStatusCode.OK)
{
var result = pashResult.Content.ReadAsStringAsync().Result;
var book = JsonConvert.DeserializeObject<Book>(result);
httpClient.Dispose();
ViewBag.categryList = book;
return View(book);
}
else
{
return Content("获取代码错误:" + pashResult.StatusCode);
}
}
#endregion
#region 查询热门图书
public ActionResult PaiHangPartial()
{
Uri uri = new Uri(path);
HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = uri;
var pashAction = httpClient.GetAsync("api/BookHot");
var pashResult = pashAction.Result;
if (pashResult.StatusCode == System.Net.HttpStatusCode.OK)
{
var result = pashResult.Content.ReadAsStringAsync().Result;
var list = JsonConvert.DeserializeObject<List<Book>>(result);
httpClient.Dispose();
return PartialView("PaiHangPartial", list);
}else
{
return Content ("获取代码错误:" + pashResult.StatusCode);
}
}
#endregion
#region 图书详情
public ActionResult Detail(string ticket,int? id)
{
Uri uri = new Uri(path);
HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = uri;
HttpContent context = new StringContent(ticket);
context.Headers.Add("Authorization", "BasicAuth" + ticket);
var pashAction = httpClient.GetAsync("api/Book/id="+id);
var pashResult = pashAction.Result;
if (pashResult.StatusCode == System.Net.HttpStatusCode.OK)
{
var result = pashResult.Content.ReadAsStringAsync().Result;
var book = JsonConvert.DeserializeObject<Book>(result);
httpClient.Dispose();
ViewBag.categryList = book;
return View(book);
}
else
{
return Content("获取代码错误:" + pashResult.StatusCode);
}
}
#endregion
#region 查询热门图书
public ActionResult PaiHangPartial()
{
Uri uri = new Uri(path);
HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = uri;
var pashAction = httpClient.GetAsync("api/BookHot");
var pashResult = pashAction.Result;
if (pashResult.StatusCode == System.Net.HttpStatusCode.OK)
{
var result = pashResult.Content.ReadAsStringAsync().Result;
var list = JsonConvert.DeserializeObject<List<Book>>(result);
httpClient.Dispose();
return PartialView("PaiHangPartial", list);
}else
{
return Content ("获取代码错误:" + pashResult.StatusCode);
}
}
#endregion