// #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 JsonResult PersonalAudioList(string currentpage, string pagesize) { #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())//数据库操作 { #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "AudioUserId"; bool isDesc = true;//倒序 //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; if (!String.IsNullOrWhiteSpace(pagesize)) { bool isOk = int.TryParse(pagesize, out sqlPagesize); if (!isOk) { sqlPagesize = 10; } } #endregion IQueryable <Child_Audio_List_User> myIQueryable = null; myIQueryable = myOperating.Child_Audio_List_User.Where(p => p.MobilePhone == myMobilePhone); // if (myIQueryable != null) { var UserSoundTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, isDesc).ToList(); List <PersonalSoundData> myUserSoundDataList = new List <PersonalSoundData>(); if (UserSoundTable != null) { for (int i = 0; i < UserSoundTable.Count(); i++) { PersonalSoundData myUserSoundDataItem = new PersonalSoundData(); Nullable <long> myAudioId = 0; //听一听主键 Nullable <int> myAlbumId = 0; //专辑主键 string mySoundTitle = "佚名"; string myAudioWords = ""; string mySoundImage = "";//封面图片 // myAudioId = UserSoundTable[i].AudioId; #region 音乐名称和歌词 if (myAudioId != null) { Child_Audio_List myChild_Audio_List = myOperating.Child_Audio_List.FirstOrDefault(p => p.AudioId == myAudioId); if (myChild_Audio_List != null) { myAlbumId = myChild_Audio_List.AlbumId; mySoundTitle = myChild_Audio_List.AudioTitle; myAudioWords = myChild_Audio_List.AudioWords; } } #endregion // #region 背景图片 if (myAlbumId != null) { Child_Audio_Album myChild_Audio_Album = myOperating.Child_Audio_Album.FirstOrDefault(p => p.AlbumId == myAlbumId); if (myChild_Audio_Album != null) { mySoundImage = StaticVarClass.myDomain + myChild_Audio_Album.AlbumImage; } } #endregion // myUserSoundDataItem.AudioUserId = UserSoundTable[i].AudioUserId; myUserSoundDataItem.MusicTitle = mySoundTitle; myUserSoundDataItem.AudioImage = mySoundImage; myUserSoundDataItem.AudioWords = myAudioWords; myUserSoundDataItem.BgMusicUrl = StaticVarClass.myDomain + UserSoundTable[i].BgMusicUrl; myUserSoundDataItem.AudioUrl = StaticVarClass.myDomain + UserSoundTable[i].AudioUrl; myUserSoundDataItem.AddDate = UserSoundTable[i].AddDate; myUserSoundDataItem.TimeSeconds = UserSoundTable[i].TimeSeconds; myUserSoundDataItem.PlayTimes = UserSoundTable[i].PlayTimes; myUserSoundDataItem.Status = UserSoundTable[i].Status; // myUserSoundDataList.Add(myUserSoundDataItem); } myStatusData.dataPageCount = pageCount; myStatusData.dataRecordCount = recordCount; myStatusData.dataTable = myUserSoundDataList; } } myStatusData.operateStatus = 200; } } else { myStatusData.operateStatus = 5; } return(Json(myStatusData)); }
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 GetCollectList(string classid, string currentpage, string pagesize) { ///1点一点;2听一听;3看一看; ///4课程讲解;5幼儿公开课;6教育技能; ///7操作说明;8教师社区;9精彩瞬间; #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())//数据库操作 { #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "CollectDate"; bool isDesc = true;//倒序 //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; if (!String.IsNullOrWhiteSpace(pagesize)) { bool isOk = int.TryParse(pagesize, out sqlPagesize); if (!isOk) { sqlPagesize = 10; } } int myInt = 0; #endregion if (!String.IsNullOrWhiteSpace(classid)) { bool isInt = int.TryParse(classid, out myInt); } // IQueryable <User_Collect> myIQueryable = null; if (myInt > 0) { myIQueryable = myOperating.User_Collect.Where(p => p.MobilePhone == myMobilePhone && p.ClassId == myInt); } else { myIQueryable = myOperating.User_Collect.Where(p => p.MobilePhone == myMobilePhone); } // if (myIQueryable != null) { List <collectData> collectDataList = new List <collectData>(); var CollcetTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, isDesc).Select(s => new { CollectId = s.CollectId, ClassId = s.ClassId, AboutId = s.AboutId, AboutTitle = s.AboutTitle, AboutImage = s.AboutImage, AboutSummary = s.AboutSummary, CollectDate = s.CollectDate }).ToList(); for (int i = 0; i < CollcetTable.Count; i++) { collectData collectDataItem = new collectData(); collectDataItem.CollectId = CollcetTable[i].CollectId; collectDataItem.ClassId = CollcetTable[i].ClassId; long aboutId = CollcetTable[i].AboutId; #region 听一听返回时长和播放次数 if (collectDataItem.ClassId == 2) { //听一听返回时长和播放次数 Child_Audio_List myChild_Audio_List = myOperating.Child_Audio_List.FirstOrDefault(p => p.AudioId == aboutId); if (myChild_Audio_List != null) { collectDataItem.TimeSeconds = myChild_Audio_List.TimeSeconds; collectDataItem.PlayTimes = myChild_Audio_List.PlayTimes; } } #endregion collectDataItem.AboutId = aboutId; collectDataItem.AboutTitle = CollcetTable[i].AboutTitle; collectDataItem.AboutImage = CollcetTable[i].AboutImage; collectDataItem.AboutSummary = CollcetTable[i].AboutSummary; collectDataItem.CollectDate = CollcetTable[i].CollectDate; collectDataList.Add(collectDataItem); } // myStatusData.dataPageCount = pageCount; myStatusData.dataRecordCount = recordCount; myStatusData.dataTable = collectDataList; } myStatusData.operateStatus = 200; } } else { myStatusData.operateStatus = 5; } return(Json(myStatusData)); }
public JsonResult AlbumList(string classid, string currentpage, string pagesize) { string mobilePhone = "";// // DataOptionClass myDataOptionClass = new DataOptionClass(); // StatusData myStatusData = new StatusData();//返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; } #endregion using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "OrderBy"; // //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; if (!String.IsNullOrWhiteSpace(pagesize)) { bool isOk = int.TryParse(pagesize, out sqlPagesize); if (!isOk) { sqlPagesize = 10; } } #endregion IQueryable <Child_Audio_Album> myIQueryable = null; if (!String.IsNullOrWhiteSpace(classid)) { int myInt = 0; bool isOk = int.TryParse(classid, out myInt); if (isOk) { myIQueryable = myOperating.Child_Audio_Album.Where(p => p.ClassId == myInt && p.Status == 200); } else { myIQueryable = null; } } else { myIQueryable = myOperating.Child_Audio_Album.Where(p => p.Status == 200); } // if (myIQueryable != null) { DataMethodClass myDataMethodClass = new DataMethodClass(); List <AudioAlbumData> myAudioAlbumDataList = new List <AudioAlbumData>(); var BookTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, true).Select(s => new { AlbumId = s.AlbumId, AlbumTitle = s.AlbumTitle, Anchor = s.Anchor, AlbumImage = StaticVarClass.myDomain + s.AlbumImage, AlbumDescrib = s.AlbumDescrib, AudioCount = s.AudioCount, PlayTimes = s.PlayTimes, ClassId = s.ClassId }).ToList(); if (BookTable != null) { for (int i = 0; i < BookTable.Count(); i++) { AudioAlbumData myAudioAlbumData = new AudioAlbumData(); int myInt = BookTable[i].AlbumId; int ListCount = 0;//总共数量 Child_Audio_List myChild_Audio_List = new Child_Audio_List(); ListCount = myOperating.Child_Audio_List.Count(p => p.AlbumId == myInt); // myAudioAlbumData.AlbumId = BookTable[i].AlbumId; myAudioAlbumData.AlbumTitle = BookTable[i].AlbumTitle; myAudioAlbumData.Anchor = BookTable[i].Anchor; myAudioAlbumData.AlbumImage = BookTable[i].AlbumImage; myAudioAlbumData.AlbumDescrib = BookTable[i].AlbumDescrib; myAudioAlbumData.AudioCount = ListCount; myAudioAlbumData.PlayTimes = myDataOptionClass.GetReadPlayTimes(2, myInt); myAudioAlbumData.ClassName = myDataMethodClass.GetAudioClassName(BookTable[i].ClassId); myAudioAlbumDataList.Add(myAudioAlbumData); } } myStatusData.dataPageCount = pageCount; myStatusData.dataRecordCount = recordCount; myStatusData.dataTable = myAudioAlbumDataList; } myStatusData.operateStatus = 200; } return(Json(myStatusData)); }
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)); }
// #region 用户上传的音频列表 public ActionResult UserAudioList(string mobilephone, string currentpage, 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 = "用户上传音频管理";//栏目主题 // ViewBag.mobilephone = mobilephone; ViewBag.DataList = null; // StatusData myStatusData = new StatusData(); //返回状态 // using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities()) //数据库操作 { #region 除 if (del > 0) { Child_Audio_List_User myDelRecord = myOperating.Child_Audio_List_User.FirstOrDefault(p => p.AudioUserId == del); if (myDelRecord != null) { FunctionClass.delFile(myDelRecord.AudioUrl); myOperating.Child_Audio_List_User.Remove(myDelRecord); myOperating.SaveChanges(); } } #endregion #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "AudioUserId"; bool isDesc = true;//倒序 // //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; #endregion IQueryable <Child_Audio_List_User> myIQueryable = null; if (!String.IsNullOrWhiteSpace(mobilephone)) { myIQueryable = myOperating.Child_Audio_List_User.Where(p => p.MobilePhone == mobilephone); } else { myIQueryable = myOperating.Child_Audio_List_User; } // if (myIQueryable != null) { IQueryable <Child_Audio_List_User> UserSoundTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, isDesc); // List <UserSoundData> myUserSoundDataList = new List <UserSoundData>(); if (UserSoundTable != null) { foreach (Child_Audio_List_User item in UserSoundTable) { UserSoundData myUserSoundDataItem = new UserSoundData(); Nullable <long> myAudioId = 0;//听一听主键 string myAudioWords = ""; string mySoundTitle = "佚名"; // myAudioId = item.AudioId; #region 音乐名称和时长 if (myAudioId != null) { Child_Audio_List myChild_Audio_List = myOperating.Child_Audio_List.FirstOrDefault(p => p.AudioId == myAudioId); if (myChild_Audio_List != null) { mySoundTitle = myChild_Audio_List.AudioTitle; myAudioWords = myChild_Audio_List.AudioWords; } } #endregion // myUserSoundDataItem.AudioUserId = item.AudioUserId; myUserSoundDataItem.MobilePhone = item.MobilePhone; myUserSoundDataItem.MusicTitle = mySoundTitle; if (!String.IsNullOrWhiteSpace(item.BgMusicUrl)) { myUserSoundDataItem.BgMusicUrl = StaticVarClass.myDomain + item.BgMusicUrl; } myUserSoundDataItem.AudioWords = myAudioWords; if (!String.IsNullOrWhiteSpace(item.AudioUrl)) { myUserSoundDataItem.AudioUrl = StaticVarClass.myDomain + item.AudioUrl; } myUserSoundDataItem.AddDate = item.AddDate; myUserSoundDataItem.PlayTimes = item.PlayTimes; // myUserSoundDataList.Add(myUserSoundDataItem); } ViewBag.DataList = myUserSoundDataList; } // #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 } } return(View()); }
// #region 音频添加-编辑 public ActionResult AudioAdd(AudioListModel model, string ReturnUrl, Nullable <long> myid = 0, int AlbumId = 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 取出数据 Child_Audio_List editRecord = myOperating.Child_Audio_List.FirstOrDefault(p => p.AudioId == mySelfId); if (editRecord != null) { model.AudioId = editRecord.AudioId; model.AlbumId = editRecord.AlbumId; model.AudioTitle = editRecord.AudioTitle; model.AudioUrl = editRecord.AudioUrl; model.AudioWords = editRecord.AudioWords; // #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) { Child_Audio_List addRecord = new Child_Audio_List(); addRecord.AlbumId = model.AlbumId; addRecord.AudioTitle = model.AudioTitle; addRecord.AudioUrl = model.AudioUrl; addRecord.AudioWords = model.AudioWords; addRecord.AddDate = DateTime.Now; addRecord.TimeSeconds = AllTimeSecond; addRecord.PlayTimes = 0; addRecord.OrderBy = model.OrderBy; addRecord.Status = 200; // myOperating.Child_Audio_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) { Child_Audio_List editSaveRecord = myOperating.Child_Audio_List.FirstOrDefault(p => p.AudioId == model.AudioId); if (editSaveRecord != null) { editSaveRecord.AudioTitle = model.AudioTitle; editSaveRecord.AudioUrl = model.AudioUrl; editSaveRecord.AudioWords = model.AudioWords; editSaveRecord.TimeSeconds = AllTimeSecond; editSaveRecord.OrderBy = model.OrderBy; // myOperating.SaveChanges(); // return(RedirectToLocal(ReturnUrl)); } } else { ModelState.AddModelError("", "输入错误"); } #endregion } else { //初次加载-添加 model.AlbumId = AlbumId; //类别编号 model.Operate = "add"; #region 默认值 try { model.OrderBy = myOperating.Child_Audio_List.Where(p => p.AlbumId == AlbumId).Max(p => p.OrderBy) + 1; } catch { model.OrderBy = 0; } if (model.OrderBy == null) { model.OrderBy = 1; } #endregion } } // return(View(model)); }
// #region 音频列表 public ActionResult AudioList(string albumid, string currentpage, 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 = "音频管理";//栏目主题 // ViewBag.AlbumId = albumid; 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) { Child_Audio_List myDelRecord = myOperating.Child_Audio_List.FirstOrDefault(p => p.AudioId == del); if (myDelRecord != null) { FunctionClass.delFile(myDelRecord.AudioImage); myOperating.Child_Audio_List.Remove(myDelRecord); #region 步删除收藏中的内容 DataOptionClass myDataOptionClass = new DataOptionClass(); myDataOptionClass.CollectOption(2, del, true);//删除收藏中的内容 #endregion myOperating.SaveChanges(); } } #endregion #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "OrderBy"; bool isDesc = true;//倒序 // //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; #endregion IQueryable <Child_Audio_List> myIQueryable = null; if (!String.IsNullOrWhiteSpace(albumid)) { int myInt = 0; bool isOk = int.TryParse(albumid, out myInt); if (isOk) { myIQueryable = myOperating.Child_Audio_List.Where(p => p.AlbumId == myInt); } else { myIQueryable = null; } } // if (myIQueryable != null) { List <Child_Audio_List> BookTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, isDesc).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 } } return(View()); }