// #region 阅读播放次数加一 public bool TimesAdd(int classid, long aboutid) { bool isOk = false; using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { try { switch (classid) {///1点一点;2听一听;3看一看; ///4课程讲解;5幼儿公开课;6教育技能; ///7操作说明;8教师社区;9精彩瞬间;12用户录音 case 1: //点一点 Child_Book_Click myChild_Book_Click = new Child_Book_Click(); myChild_Book_Click = myOperating.Child_Book_Click.FirstOrDefault(p => p.BookID == aboutid); if (myChild_Book_Click != null) { myChild_Book_Click.ReadCount = myChild_Book_Click.ReadCount + 1; myOperating.SaveChanges(); isOk = true; } break; case 2: //2听一听 Child_Audio_List myChild_Audio_List = new Child_Audio_List(); myChild_Audio_List = myOperating.Child_Audio_List.FirstOrDefault(p => p.AudioId == aboutid); if (myChild_Audio_List != null) { myChild_Audio_List.PlayTimes = myChild_Audio_List.PlayTimes + 1; myOperating.SaveChanges(); isOk = true; } break; case 3: //3看一看 Child_Video_List myChild_Video_List = new Child_Video_List(); myChild_Video_List = myOperating.Child_Video_List.FirstOrDefault(p => p.VideoId == aboutid); if (myChild_Video_List != null) { myChild_Video_List.PlayTimes = myChild_Video_List.PlayTimes + 1; myOperating.SaveChanges(); isOk = true; } break; case 4: case 5: case 6: case 7: //4课程讲解;5幼儿公开课;6教育技能;7操作说明 Teacher_Video_List myTeacher_Video_List = new Teacher_Video_List(); myTeacher_Video_List = myOperating.Teacher_Video_List.FirstOrDefault(p => p.VideoId == aboutid); if (myTeacher_Video_List != null) { myTeacher_Video_List.PlayTimes = myTeacher_Video_List.PlayTimes + 1; myOperating.SaveChanges(); isOk = true; } break; case 8: //8教师社区 Teacher_Article myTeacher_Article = new Teacher_Article(); myTeacher_Article = myOperating.Teacher_Article.FirstOrDefault(p => p.ArticlId == aboutid); if (myTeacher_Article != null) { myTeacher_Article.ReadTimes = myTeacher_Article.ReadTimes + 1; myOperating.SaveChanges(); isOk = true; } break; case 9: //9精彩瞬间 Discover_Article myDiscover_Article = new Discover_Article(); myDiscover_Article = myOperating.Discover_Article.FirstOrDefault(p => p.ArticlId == aboutid); if (myDiscover_Article != null) { myDiscover_Article.ReadTimes = myDiscover_Article.ReadTimes + 1; myOperating.SaveChanges(); isOk = true; } break; case 12: //用户录音 Child_Audio_List_User myChild_Audio_List_User = new Child_Audio_List_User(); myChild_Audio_List_User = myOperating.Child_Audio_List_User.FirstOrDefault(p => p.AudioUserId == aboutid); if (myChild_Audio_List_User != null) { myChild_Audio_List_User.PlayTimes = myChild_Audio_List_User.PlayTimes + 1; myOperating.SaveChanges(); isOk = true; } break; } } catch { } } return(isOk); }
public bool CollectOption(int classid, long aboutid, bool editOrdel) { ///editOrdel=true编辑;false删除 ///1点一点;2听一听;3看一看; ///4课程讲解;5幼儿公开课;6教育技能; ///7操作说明;8教师社区;9精彩瞬间; // bool OptionComplet = false; using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities()) //数据库操作 { bool isExict = false; //是否存在 string myCoverImage = ""; //图片 string myTitle = ""; //标题 string mySummart = ""; //摘要 if (!editOrdel) { #region 根据收藏类别取出图片和标题 switch (classid) {///1点一点;2听一听;3看一看; ///4课程讲解;5幼儿公开课;6教育技能; ///7操作说明;8教师社区;9精彩瞬间; case 1: //点一点 Child_Book_Click myChild_Book_Click = new Child_Book_Click(); myChild_Book_Click = myOperating.Child_Book_Click.FirstOrDefault(p => p.BookID == aboutid); if (myChild_Book_Click != null) { myTitle = myChild_Book_Click.BookName; if (!String.IsNullOrWhiteSpace(myChild_Book_Click.BookImage)) { myCoverImage = StaticVarClass.BookClickResourceUrl + myChild_Book_Click.BookImage; } isExict = true; } break; case 2: //2听一听 Child_Audio_List myChild_Audio_List = new Child_Audio_List(); myChild_Audio_List = myOperating.Child_Audio_List.FirstOrDefault(p => p.AudioId == aboutid); if (myChild_Audio_List != null) { myTitle = myChild_Audio_List.AudioTitle; if (!String.IsNullOrWhiteSpace(myChild_Audio_List.AudioImage)) { myCoverImage = StaticVarClass.myDomain + myChild_Audio_List.AudioImage; } isExict = true; } break; case 3: //3看一看 Child_Video_List myChild_Video_List = new Child_Video_List(); myChild_Video_List = myOperating.Child_Video_List.FirstOrDefault(p => p.VideoId == aboutid); if (myChild_Video_List != null) { myTitle = myChild_Video_List.VideoTitle; if (!String.IsNullOrWhiteSpace(myChild_Video_List.VideoImage)) { myCoverImage = StaticVarClass.myDomain + myChild_Video_List.VideoImage; } isExict = true; } break; case 4: case 5: case 6: case 7: //4课程讲解;5幼儿公开课;6教育技能;7操作说明 Teacher_Video_List myTeacher_Video_List = new Teacher_Video_List(); myTeacher_Video_List = myOperating.Teacher_Video_List.FirstOrDefault(p => p.VideoId == aboutid); if (myTeacher_Video_List != null) { myTitle = myTeacher_Video_List.VideoTitle; if (!String.IsNullOrWhiteSpace(myTeacher_Video_List.VideoImage)) { myCoverImage = StaticVarClass.myDomain + myTeacher_Video_List.VideoImage; } isExict = true; } break; case 8: //8教师社区 Teacher_Article myTeacher_Article = new Teacher_Article(); myTeacher_Article = myOperating.Teacher_Article.FirstOrDefault(p => p.ArticlId == aboutid); if (myTeacher_Article != null) { myTitle = myTeacher_Article.ArticleTitle; if (!String.IsNullOrWhiteSpace(myTeacher_Article.ArticleImages)) { myCoverImage = StaticVarClass.myDomain + myTeacher_Article.ArticleImages; } if (myTeacher_Article.ArticleSummary.Length > 50) { mySummart = myTeacher_Article.ArticleSummary.Substring(0, 50); } else { mySummart = myTeacher_Article.ArticleSummary; } isExict = true; } break; case 9: //9精彩瞬间 Discover_Article myDiscover_Article = new Discover_Article(); myDiscover_Article = myOperating.Discover_Article.FirstOrDefault(p => p.ArticlId == aboutid); if (myDiscover_Article != null) { myTitle = myDiscover_Article.ArticleTitle; if (!String.IsNullOrWhiteSpace(myDiscover_Article.ArticleImages)) { //取出第一幅图 string[] imageOne = myDiscover_Article.ArticleImages.Split(';'); if (imageOne.Count() > 0) { myCoverImage = StaticVarClass.myDomain + imageOne[0]; } } if (myDiscover_Article.ArticleContent.Length > 50) { mySummart = myDiscover_Article.ArticleContent.Substring(0, 50); } else { mySummart = myDiscover_Article.ArticleContent; } isExict = true; } break; } #endregion } else {//要执行删除操作,直接允许执行 isExict = true; } // if (isExict) { User_Collect myUser_Collect = myOperating.User_Collect.FirstOrDefault(p => p.ClassId == classid && p.AboutId == aboutid); if (myUser_Collect != null) { try { if (editOrdel) { myUser_Collect.AboutTitle = myTitle; myUser_Collect.AboutImage = myCoverImage; myUser_Collect.AboutSummary = mySummart; } else { myOperating.User_Collect.Remove(myUser_Collect); } myOperating.SaveChanges(); OptionComplet = true; } catch { OptionComplet = false; } } } } return(OptionComplet); }
public JsonResult AddCollect(string classid, string aboutid) { // #region 检查授权 string myMobilePhone = ""; //手机号 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion // StatusData myStatusData = new StatusData();//返回状态 // if (checkAuthCodeBool) { myMobilePhone = myAuthCodeInstance.mobilePhone; using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities()) //数据库操作 { int myClassid = 0; //类别 long myAboutid = 0; //主键 #region 判断输入参数 bool classIsNumber = false; //判断输入参数类型 bool AboutIsNumber = false; //判断输入参数类型 if (!String.IsNullOrEmpty(aboutid)) { classIsNumber = int.TryParse(classid, out myClassid); } // if (!String.IsNullOrEmpty(aboutid)) { AboutIsNumber = long.TryParse(aboutid, out myAboutid); } // if ((myClassid < 1) || (myClassid > 9) || (myAboutid < 1)) { myStatusData.operateMsg = "输入参数错误"; myStatusData.operateStatus = 400; return(Json(myStatusData)); } #endregion // #region 检查是否已经收藏 int checkUser_Collect = myOperating.User_Collect.Count(p => p.ClassId == myClassid && p.AboutId == myAboutid && p.MobilePhone == myMobilePhone); if (checkUser_Collect > 0) { myStatusData.operateMsg = "已收藏,不能重复收藏"; myStatusData.operateStatus = 400; return(Json(myStatusData)); } #endregion // bool isTeacherVideo = false; //类别为45679的收藏为true bool isExict = false; //是否存在 string myCoverImage = ""; //图片 string myTitle = ""; //标题 string mySummart = ""; //摘要 #region 根据收藏类别取出图片和标题 switch (myClassid) {///1点一点;2听一听;3看一看; ///4课程讲解;5幼儿公开课;6教育技能; ///7操作说明;8教师社区;9精彩瞬间; case 1: //点一点 #region 点一点 Child_Book_Click myChild_Book_Click = new Child_Book_Click(); myChild_Book_Click = myOperating.Child_Book_Click.FirstOrDefault(p => p.BookID == myAboutid); if (myChild_Book_Click != null) { myTitle = myChild_Book_Click.BookName; if (!String.IsNullOrWhiteSpace(myChild_Book_Click.BookOnlineUrl)) { myCoverImage = StaticVarClass.BookClickResourceUrl + myChild_Book_Click.BookOnlineUrl + "main.png"; } isExict = true; } #endregion break; case 2: //2听一听 #region 听一听 Child_Audio_List myChild_Audio_List = new Child_Audio_List(); myChild_Audio_List = myOperating.Child_Audio_List.FirstOrDefault(p => p.AudioId == myAboutid); if (myChild_Audio_List != null) { myTitle = myChild_Audio_List.AudioTitle; int AlibumId = myChild_Audio_List.AlbumId; string AudioBgImg = ""; try { AudioBgImg = myOperating.Child_Audio_Album.FirstOrDefault(p => p.AlbumId == AlibumId).AlbumImage; if (!String.IsNullOrWhiteSpace(AudioBgImg)) { myCoverImage = StaticVarClass.myDomain + AudioBgImg; } } catch { } isExict = true; } #endregion break; case 3: //3看一看 #region 一看 Child_Video_List myChild_Video_List = new Child_Video_List(); myChild_Video_List = myOperating.Child_Video_List.FirstOrDefault(p => p.VideoId == myAboutid); if (myChild_Video_List != null) { myTitle = myChild_Video_List.VideoTitle; myCoverImage = StaticVarClass.myDomain + myChild_Video_List.VideoImage; isExict = true; } #endregion break; case 4: case 5: case 6: case 7: //4课程讲解;5幼儿公开课;6教育技能;7操作说明 #region 教师社区 Teacher_Video_List myTeacher_Video_List = new Teacher_Video_List(); myTeacher_Video_List = myOperating.Teacher_Video_List.FirstOrDefault(p => p.VideoId == myAboutid); if (myTeacher_Video_List != null) { myTitle = myTeacher_Video_List.VideoTitle; myCoverImage = StaticVarClass.myDomain + myTeacher_Video_List.VideoImage; isExict = true; isTeacherVideo = true; } #endregion break; case 8: //8教师社区 #region 教师社区 Teacher_Article myTeacher_Article = new Teacher_Article(); myTeacher_Article = myOperating.Teacher_Article.FirstOrDefault(p => p.ArticlId == myAboutid); if (myTeacher_Article != null) { myTitle = myTeacher_Article.ArticleTitle; if (!String.IsNullOrWhiteSpace(myTeacher_Article.ArticleImages)) { myCoverImage = StaticVarClass.myDomain + myTeacher_Article.ArticleImages; } if ((myTeacher_Article.ArticleSummary != null) && (myTeacher_Article.ArticleSummary.Length > 50)) { mySummart = myTeacher_Article.ArticleSummary.Substring(0, 50); } else { mySummart = myTeacher_Article.ArticleSummary; } isExict = true; } #endregion break; case 9: //9精彩瞬间 #region 精彩瞬间 Discover_Article myDiscover_Article = new Discover_Article(); myDiscover_Article = myOperating.Discover_Article.FirstOrDefault(p => p.ArticlId == myAboutid); if (myDiscover_Article != null) { myTitle = myDiscover_Article.ArticleTitle; if (!String.IsNullOrWhiteSpace(myDiscover_Article.ArticleImages)) { //取出第一幅图 string[] imageOne = myDiscover_Article.ArticleImages.Split(';'); if (imageOne.Count() > 0) { myCoverImage = StaticVarClass.myDomain + imageOne[0]; } } if ((myDiscover_Article.ArticleContent != null) && (myDiscover_Article.ArticleContent.Length > 50)) { mySummart = myDiscover_Article.ArticleContent.Substring(0, 50); } else { mySummart = myDiscover_Article.ArticleContent; } isExict = true; } #endregion break; } #endregion // #region 添加到数据库 if (isExict) { try { User_Collect myUser_Collect = new User_Collect(); // myUser_Collect.ClassId = myClassid; myUser_Collect.AboutId = myAboutid; myUser_Collect.AboutTitle = myTitle; myUser_Collect.AboutImage = myCoverImage; myUser_Collect.AboutSummary = mySummart; myUser_Collect.MobilePhone = myMobilePhone; myUser_Collect.ClassId = myClassid;//收藏类别 myUser_Collect.CollectDate = DateTime.Now; myUser_Collect.IsTeacherVideo = isTeacherVideo; myUser_Collect.OrderBy = 10000; // myOperating.User_Collect.Add(myUser_Collect); myOperating.SaveChanges(); myStatusData.operateStatus = 200; } catch { myStatusData.operateStatus = -1; } } else { myStatusData.operateMsg = "不存在"; myStatusData.operateStatus = 400; } #endregion } } else { myStatusData.operateStatus = 5;//登陆失效 } return(Json(myStatusData)); }
public ActionResult Share(int classtype = 0, long aboutid = 0) { ShareModel myShareModel = new ShareModel(); myShareModel.ClassType = classtype;//属于哪一个表的内容 myShareModel.AboutTitle = "芮卡家园"; // #region 根据类别取出分享的内容 using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { switch (classtype) {///1点一点;2听一听;3看一看; ///4课程讲解;5幼儿公开课;6教育技能; ///7操作说明;8教师社区;9精彩瞬间; case 1: //点一点 #region 点一点 Child_Book_Click myChild_Book_Click = new Child_Book_Click(); myChild_Book_Click = myOperating.Child_Book_Click.FirstOrDefault(p => p.BookID == aboutid); if (myChild_Book_Click != null) { myShareModel.AboutTitle = myChild_Book_Click.BookName; if (!String.IsNullOrWhiteSpace(myChild_Book_Click.BookImage)) { myShareModel.AboutImages = StaticVarClass.BookClickResourceUrl + myChild_Book_Click.BookImage; } } #endregion return(View("ShareClick", myShareModel)); //break; case 2: //2听一听 #region 听一听 Child_Audio_List myChild_Audio_List = new Child_Audio_List(); myChild_Audio_List = myOperating.Child_Audio_List.FirstOrDefault(p => p.AudioId == aboutid); if (myChild_Audio_List != null) { myShareModel.AboutTitle = myChild_Audio_List.AudioTitle; #region 取专辑图片 int AlibumId = myChild_Audio_List.AlbumId; try { Child_Audio_Album myChild_Audio_Album = new Child_Audio_Album(); myChild_Audio_Album = myOperating.Child_Audio_Album.FirstOrDefault(p => p.AlbumId == AlibumId); if (myChild_Audio_Album != null) { if (!String.IsNullOrWhiteSpace(myChild_Audio_Album.Anchor)) { myShareModel.AboutAuthor = myChild_Audio_Album.Anchor; } if (!String.IsNullOrWhiteSpace(myChild_Audio_Album.AlbumImage)) { myShareModel.AboutImages = StaticVarClass.myDomain + myChild_Audio_Album.AlbumImage; } } } catch { } #endregion if (!String.IsNullOrWhiteSpace(myChild_Audio_List.AudioUrl)) { myShareModel.AboutAudio = StaticVarClass.myDomain + myChild_Audio_List.AudioUrl; } myShareModel.AboutContent = myChild_Audio_List.AudioWords; DateTime myDateTime = DateTime.Now; DateTime.TryParse(myChild_Audio_List.AddDate.ToString(), out myDateTime); myShareModel.AddDate = myDateTime; } #endregion break; case 3: //3看一看 #region 一看 Child_Video_List myChild_Video_List = new Child_Video_List(); myChild_Video_List = myOperating.Child_Video_List.FirstOrDefault(p => p.VideoId == aboutid); if (myChild_Video_List != null) { myShareModel.AboutTitle = myChild_Video_List.VideoTitle; if (!String.IsNullOrWhiteSpace(myChild_Video_List.VideoImage)) { myShareModel.AboutImages = StaticVarClass.myDomain + myChild_Video_List.VideoImage; } if (!String.IsNullOrWhiteSpace(myChild_Video_List.VideoUrl)) { myShareModel.AboutVideo = StaticVarClass.myDomain + myChild_Video_List.VideoUrl; } myShareModel.AboutContent = myChild_Video_List.VideoDes; DateTime myDateTime = DateTime.Now; DateTime.TryParse(myChild_Video_List.AddDate.ToString(), out myDateTime); myShareModel.AddDate = myDateTime; } #endregion break; case 4: case 5: case 6: case 7: //4课程讲解;5幼儿公开课;6教育技能;7操作说明 #region 教师视频 Teacher_Video_List myTeacher_Video_List = new Teacher_Video_List(); myTeacher_Video_List = myOperating.Teacher_Video_List.FirstOrDefault(p => p.VideoId == aboutid); if (myTeacher_Video_List != null) { myShareModel.AboutTitle = myTeacher_Video_List.VideoTitle; if (!String.IsNullOrWhiteSpace(myTeacher_Video_List.VideoImage)) { myShareModel.AboutImages = StaticVarClass.myDomain + myTeacher_Video_List.VideoImage; } if (!String.IsNullOrWhiteSpace(myTeacher_Video_List.VideoUrl)) { myShareModel.AboutVideo = StaticVarClass.myDomain + myTeacher_Video_List.VideoUrl; } myShareModel.AboutContent = myTeacher_Video_List.VideoDes; DateTime myDateTime = DateTime.Now; DateTime.TryParse(myTeacher_Video_List.AddDate.ToString(), out myDateTime); myShareModel.AddDate = myDateTime; } #endregion break; case 8: //8教师社区 #region 教师社区 Teacher_Article myTeacher_Article = new Teacher_Article(); myTeacher_Article = myOperating.Teacher_Article.FirstOrDefault(p => p.ArticlId == aboutid); if (myTeacher_Article != null) { myShareModel.AboutTitle = myTeacher_Article.ArticleTitle; if (!String.IsNullOrWhiteSpace(myTeacher_Article.ArticleImages)) { myShareModel.AboutImages = StaticVarClass.myDomain + myTeacher_Article.ArticleImages; } if (!String.IsNullOrWhiteSpace(myTeacher_Article.ArticleVideo)) { myShareModel.AboutVideo = StaticVarClass.myDomain + myTeacher_Article.ArticleVideo; } myShareModel.AboutContent = myTeacher_Article.ArticleContent; DateTime myDateTime = DateTime.Now; DateTime.TryParse(myTeacher_Article.AddDate.ToString(), out myDateTime); myShareModel.AddDate = myDateTime; } #endregion break; case 9: //9精彩瞬间 #region 精彩瞬间 Discover_Article myDiscover_Article = new Discover_Article(); myDiscover_Article = myOperating.Discover_Article.FirstOrDefault(p => p.ArticlId == aboutid); if (myDiscover_Article != null) { myShareModel.AboutTitle = myDiscover_Article.ArticleTitle; myShareModel.AboutImages = myDiscover_Article.ArticleImages; myShareModel.AboutVideo = myDiscover_Article.ArticleVideo; myShareModel.AboutContent = myDiscover_Article.ArticleContent; DateTime myDateTime = DateTime.Now; DateTime.TryParse(myDiscover_Article.AddDate.ToString(), out myDateTime); myShareModel.AddDate = myDateTime; } #endregion break; } } #endregion return(View(myShareModel)); }
public ActionResult TeacherVideoList(int currentpage = 1, int ClassId = 0, int LessonId = 0, long del = 0) { #region 翻页定义 ViewBag.CurrentPage = 0; //当前页 ViewBag.PPage = 0; //上一页 ViewBag.NPage = 0; //下一页 ViewBag.PageCount = 0; //总页数 ViewBag.RecordCount = 0; //记录总数 ViewBag.IsFirstPage = ""; //第一条记录,禁用首页和上一页 ViewBag.IsEndPage = ""; //最后条记录,禁用首页和下一页 #endregion // ViewBag.Headline = "教师视频管理";//栏目主题 #region 栏目名称 switch (ClassId) { case 1: ViewBag.Headline = "芮卡课程讲解"; break; case 2: ViewBag.Headline = "幼儿公开课"; break; case 3: ViewBag.Headline = "教育技能"; break; case 4: ViewBag.Headline = "芮卡多媒体操作说明"; break; } #endregion // ViewBag.DataList = null; ViewBag.RecordItem = null; ViewBag.Operate = "add"; //add添加;edit编辑取出数据;editsave编辑保存 // StatusData myStatusData = new StatusData(); //返回状态 // using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities()) //数据库操作 { #region 除 if (del > 0) { Teacher_Video_List myDelRecord = myOperating.Teacher_Video_List.FirstOrDefault(p => p.VideoId == del); if (myDelRecord != null) { FunctionClass.delFile(myDelRecord.VideoImage); FunctionClass.delFile(myDelRecord.VideoUrl); myOperating.Teacher_Video_List.Remove(myDelRecord); #region 步删除收藏中的内容 DataOptionClass myDataOptionClass = new DataOptionClass(); myDataOptionClass.CollectOption(4, del, true); //删除收藏中的内容 myDataOptionClass.CollectOption(5, del, true); //删除收藏中的内容 myDataOptionClass.CollectOption(6, del, true); //删除收藏中的内容 myDataOptionClass.CollectOption(7, del, true); //删除收藏中的内容 #endregion myOperating.SaveChanges(); } } #endregion // #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "Recommended"; string orderbyfiled2 = "OrderBy"; // //当前页 int sqlCurrentpage = currentpage; if (sqlCurrentpage < 1) { sqlCurrentpage = 1; } //页大小 int sqlPagesize = 10; #endregion // #region 取出内容 IQueryable <Teacher_Video_List> myIQueryable = null; if (ClassId > 0) { if ((ClassId == 1) && (LessonId > 0)) { myIQueryable = myOperating.Teacher_Video_List.Where(p => p.ClassId == ClassId && p.LessonId == LessonId); } else { myIQueryable = myOperating.Teacher_Video_List.Where(p => p.ClassId == ClassId); } } else { myIQueryable = myOperating.Teacher_Video_List; } // if (myIQueryable != null) { List <Teacher_Video_List> BookTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, true, orderbyfiled2).ToList(); // ViewBag.DataList = BookTable; #region 页数取值 ViewBag.CurrentPage = sqlCurrentpage; ViewBag.PageCount = pageCount; ViewBag.RecordCount = recordCount; if (sqlCurrentpage > 1) { ViewBag.PPage = sqlCurrentpage - 1; } else { ViewBag.IsFirstPage = "disabled"; ViewBag.PPage = 1; } if (sqlCurrentpage < pageCount) { ViewBag.NPage = sqlCurrentpage + 1; } else { ViewBag.NPage = sqlCurrentpage; ViewBag.IsEndPage = "disabled"; } #endregion } #endregion // ViewBag.ClassId = ClassId; //当前类别 ViewBag.LessonId = LessonId; //当前课程门类 // #region 芮卡课程讲解需要取出课程门类 if (ClassId == 1) {//芮卡课程讲解 List <Teacher_Video_Class_Lesson> LessonTable = myOperating.Teacher_Video_Class_Lesson.Where(p => p.Status == 200).OrderByDescending(p => p.OrderBy).ToList(); ViewBag.DataListLesson = LessonTable; } #endregion } return(View()); }
// #region 视频添加-编辑 public ActionResult TeacherVideoAdd(TeacherVideoListModel model, string ReturnUrl, Nullable <long> myid = 0, int ClassId = 0, int LessonId = 0) { #region 获取来路路径 if (System.Web.HttpContext.Current.Request.UrlReferrer != null) { ViewBag.ReturnUrl = System.Web.HttpContext.Current.Request.UrlReferrer.PathAndQuery; } #endregion ViewBag.Headline = "音频添加"; //栏目主题 ViewBag.ButtonValue = "添加"; //按钮名称 // int AllTimeSecond = 0; int myMinute = 0; int mySecond = 0; // using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { if ((myid > 0) && (model.Operate == null)) { long mySelfId = 0; long.TryParse(myid.ToString(), out mySelfId); ViewBag.Headline = "视频编辑"; ViewBag.ButtonValue = "修改"; model.Operate = "edit"; // #region 取出数据 Teacher_Video_List editRecord = myOperating.Teacher_Video_List.FirstOrDefault(p => p.VideoId == mySelfId); if (editRecord != null) { ClassId = editRecord.ClassId; model.VideoId = editRecord.VideoId; model.ClassId = editRecord.ClassId; model.LessonId = editRecord.LessonId; model.VideoTitle = editRecord.VideoTitle; model.VideoImage = editRecord.VideoImage; model.VideoUrl = editRecord.VideoUrl; model.VideoDes = editRecord.VideoDes; model.Recommended = editRecord.Recommended; // if (model.Recommended == null) { model.Recommended = 0; } // #region 时间拆分成分秒 if (editRecord.TimeSeconds != null) { int.TryParse(editRecord.TimeSeconds.ToString(), out AllTimeSecond); } myMinute = AllTimeSecond / 60; mySecond = AllTimeSecond % 60; model.TimeMinute = myMinute; model.TimeSeconds = mySecond; #endregion model.OrderBy = editRecord.OrderBy; } #endregion } else if (model.Operate == "add") { #region 时间组合分秒 if (model.TimeMinute != null) { int.TryParse(model.TimeMinute.ToString(), out myMinute); } if (model.TimeSeconds != null) { int.TryParse(model.TimeSeconds.ToString(), out mySecond); } AllTimeSecond = myMinute * 60 + mySecond; #endregion // #region 保存添加 if (ModelState.IsValid) { Teacher_Video_List addRecord = new Teacher_Video_List(); addRecord.ClassId = model.ClassId; addRecord.LessonId = model.LessonId; addRecord.VideoTitle = model.VideoTitle; addRecord.VideoImage = model.VideoImage; addRecord.VideoUrl = model.VideoUrl; addRecord.VideoDes = model.VideoDes; addRecord.AddDate = DateTime.Now; addRecord.Recommended = model.Recommended; addRecord.TimeSeconds = AllTimeSecond; addRecord.PlayTimes = 0; addRecord.OrderBy = model.OrderBy; addRecord.Status = 200; // myOperating.Teacher_Video_List.Add(addRecord); myOperating.SaveChanges(); // return(RedirectToLocal(ReturnUrl)); } else { ModelState.AddModelError("", "输入错误"); } #endregion } else if (model.Operate == "edit") { #region 时间组合分秒 if (model.TimeMinute != null) { int.TryParse(model.TimeMinute.ToString(), out myMinute); } if (model.TimeSeconds != null) { int.TryParse(model.TimeSeconds.ToString(), out mySecond); } AllTimeSecond = myMinute * 60 + mySecond; #endregion // #region 保存编辑 if (ModelState.IsValid) { Teacher_Video_List editSaveRecord = myOperating.Teacher_Video_List.FirstOrDefault(p => p.VideoId == model.VideoId); if (editSaveRecord != null) { editSaveRecord.ClassId = model.ClassId; editSaveRecord.LessonId = model.LessonId; editSaveRecord.VideoTitle = model.VideoTitle; editSaveRecord.VideoImage = model.VideoImage; editSaveRecord.VideoUrl = model.VideoUrl; editSaveRecord.VideoDes = model.VideoDes; editSaveRecord.Recommended = model.Recommended; editSaveRecord.TimeSeconds = AllTimeSecond; editSaveRecord.OrderBy = model.OrderBy; // myOperating.SaveChanges(); // return(RedirectToLocal(ReturnUrl)); } } else { ModelState.AddModelError("", "输入错误"); } #endregion } else { //初次加载-添加 model.ClassId = ClassId; //类别编号 model.LessonId = LessonId; model.Operate = "add"; #region 默认值 try { model.OrderBy = myOperating.Teacher_Video_List.Where(p => p.ClassId == ClassId).Max(p => p.OrderBy) + 1; } catch { model.OrderBy = 0; } if (model.OrderBy == null) { model.OrderBy = 1; } #endregion } #region 芮卡课程讲解需要取出课程门类 if (ClassId == 1) {//芮卡课程讲解 List <Teacher_Video_Class_Lesson> LessonTable = myOperating.Teacher_Video_Class_Lesson.Where(p => p.Status == 200).OrderByDescending(p => p.OrderBy).ToList(); ViewBag.DataListLesson = LessonTable; } #endregion } // return(View(model)); }