public async Task <IHttpActionResult> GetDetail(detailModel model) { try { string cacheName = "Detail" + model.type + model.id; if (HttpRuntime.Cache[cacheName] != null) { var ratingTopCache = HttpRuntime.Cache[cacheName] as RatingTopTvModel; return(Ok(new BaseResponseModel { HttpStatusCode = HttpStatusCode.OK, Data = ratingTopCache })); } if (model.type.ToLower() == "tv" || model.type.ToLower() == "movie") { var _detail = await ApiService.Detail(apiUrl, apiKey, model); var _detailCredits = await ApiService.DetailCredits(apiUrl, apiKey, model); var detailTvModel = new DetailTvsMovieModel { detailMovieTvCreditModel = _detailCredits, detailMovieTvModel = _detail }; HttpRuntime.Cache.Insert(cacheName, detailTvModel, null, DateTime.Now.AddMinutes(cacheTime), System.Web.Caching.Cache.NoSlidingExpiration); return(Ok(new BaseResponseModel { HttpStatusCode = HttpStatusCode.OK, Data = detailTvModel })); } return(Ok(new BaseResponseModel { HttpStatusCode = HttpStatusCode.BadRequest, Data = null, ExeptionMessage = "error" })); } catch (Exception ex) { return(Ok(new BaseResponseModel { HttpStatusCode = HttpStatusCode.BadRequest, Data = null, ExeptionMessage = ex.Message })); } }
public async Task <ActionResult> Detail(detailModel model) { var requestDetail = await HttpRequestFactory.Post(apiUrl + "api/MovieApi/GetDetail", model); var detailContent = await requestDetail.Content.ReadAsStringAsync(); var detailResult = JsonConvert.DeserializeObject <BaseResponseModel>(detailContent); if (detailResult.HttpStatusCode == HttpStatusCode.OK) { var moviedetail = JsonConvert.DeserializeObject <DetailTvsMovieModel>(JsonConvert.SerializeObject(detailResult.Data)); return(View(moviedetail)); } return(View(new DetailTvsMovieModel())); }
public detailModel GetContent(string where) { detailModel model = new detailModel(); //获得导航Model string TypeSql = string.Format("SELECT 节目编号,节目名称,节目简介 FROM CACV"); if (!string.IsNullOrEmpty(where)) { TypeSql += string.Format(" where {0}", where); } //获得typemodellist列表 //连接数据库 Client client2 = new Client(); if (!client2.Connect(kbaseIP, 4567, "DBOWN", string.Empty)) { client2.Close(); } RecordSet recordSet_Type = client2.OpenRecordSet(TypeSql); if (recordSet_Type != null && recordSet_Type.GetCount() > 0) { int FieldCount = recordSet_Type.GetFieldCount(); while (!recordSet_Type.IsEOF() && FieldCount > 0) { model.code = recordSet_Type.GetValue(0); model.title = recordSet_Type.GetValue(1); model.content = recordSet_Type.GetValue(2); model.path = "http://rtsp.cnki.net/" + model.code.Substring(0, model.code.Length - 1) + "/" + model.code + ".mp4"; } recordSet_Type.Close(); } return(model); }
/// <summary> /// 获取详情 /// </summary> /// <param name="id"></param> /// <param name="type"></param> public void GetInfoDetail(string id, string type) { NYAnswerBll nybll = new NYAnswerBll(); detailModel model = new detailModel(); if (type == "spider")//说明是抓取的数据(mysql中查找) { spiderdata smodel = resbll.GetModel(Convert.ToInt32(id)); model.title = smodel.title; model.content = smodel.content; model.code = smodel.id.ToString(); model.releaseTime = smodel.releaseTime.ToString(); model.resource = smodel.resource; } else if (type == "cacv")//视频 { model = nybll.GetContent(string.Format(" 节目编号={0}", id)); } else if (type == "cacb")//图书 { } }
public IActionResult Index(int id) { var dbh = DbContext.Get(); var data = dbh.GetEntityDB <YogaClass>().GetById(id); if (data == null || data.disabled) { return(ShowErrorPage("课程不存在!")); } detailModel mdl = new detailModel(); mdl.data = data; Claim idobj; if (User != null && (idobj = User.FindFirst(ClaimTypes.Sid)) != null) { var userid = idobj.Value.AsInt(); if (userid > 0) { mdl.ordered = dbh.Db.Queryable <YogaOrder>().Count(ii => ii.userId == userid && ii.classId == id) > 0; } } return(View(mdl)); }
public static async Task <DetailMovieTvCreditModel> DetailCredits(string apiUrl, string apiKey, detailModel model) { try { var moviedbUrl = apiUrl + $"3/{model.type.ToLower().ToString()}/{model.id}/credits?api_key={apiKey}&language=en-US&page=1"; var requestMovives = await HttpRequestFactory.Get(moviedbUrl); var MoviveContent = await requestMovives.Content.ReadAsStringAsync(); var tvTopRates = JsonConvert.DeserializeObject <DetailMovieTvCreditModel>(MoviveContent); return(tvTopRates); } catch (Exception ex) { return(new DetailMovieTvCreditModel()); } }