Example #1
0
        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);
        }
Example #2
0
        //
        #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);
        }
Example #3
0
 public ActionResult ItemList(int currentpage = 1, int ClassId = 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 = "图书管理";//栏目主题
     //
     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_Book_Click myDelRecord = myOperating.Child_Book_Click.FirstOrDefault(p => p.BookID == del);
             if (myDelRecord != null)
             {
                 myOperating.Child_Book_Click.Remove(myDelRecord);
                 #region  步删除收藏中的内容
                 DataOptionClass myDataOptionClass = new DataOptionClass();
                 myDataOptionClass.CollectOption(1, del, true);//删除收藏中的内容
                 #endregion
                 myOperating.SaveChanges();
             }
         }
         #endregion
         //
         #region 翻页属性
         int    recordCount  = 0;
         int    pageCount    = 0;
         string orderbyfiled = "OrderBy";
         //
         //当前页
         int sqlCurrentpage = currentpage;
         if (sqlCurrentpage < 1)
         {
             sqlCurrentpage = 1;
         }
         //页大小
         int sqlPagesize = 10;
         #endregion
         //
         #region 取出内容
         IQueryable <Child_Book_Click> myIQueryable = null;
         if (ClassId > 0)
         {
             myIQueryable = myOperating.Child_Book_Click.Where(p => p.BookClassID == ClassId);
         }
         else
         {
             myIQueryable = myOperating.Child_Book_Click;
         }
         //
         if (myIQueryable != null)
         {
             List <Child_Book_Click> BookTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, true).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;//当前类别
         //
         List <Child_Book_Click_Class> ClassTable = myOperating.Child_Book_Click_Class.Where(p => p.Status == 200).OrderByDescending(p => p.OrderBy).ToList();
         ViewBag.DataListClass = ClassTable;
     }
     return(View());
 }
Example #4
0
 //
 #region 内容添加-编辑
 public ActionResult ItemAdd(BookClickModel model, string ReturnUrl, Nullable <long> myid = 0, Nullable <int> ClassId = 0)
 {
     #region 获取来路路径
     if (System.Web.HttpContext.Current.Request.UrlReferrer != null)
     {
         ViewBag.ReturnUrl = System.Web.HttpContext.Current.Request.UrlReferrer.PathAndQuery;
     }
     #endregion
     ViewBag.Headline    = "图书添加";                                         //栏目主题
     ViewBag.ButtonValue = "添加";                                           //按钮名称
     //
     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_Book_Click editRecord = myOperating.Child_Book_Click.FirstOrDefault(p => p.BookID == mySelfId);
             if (editRecord != null)
             {
                 ClassId             = editRecord.BookClassID;
                 model.BookID        = editRecord.BookID;
                 model.BookClassID   = editRecord.BookClassID;
                 model.BookName      = editRecord.BookName;
                 model.BookOnlineUrl = editRecord.BookOnlineUrl;
                 model.ScreenH       = editRecord.ScreenH;
                 model.OrderBy       = editRecord.OrderBy;
             }
             #endregion
         }
         else if (model.Operate == "add")
         {
             #region 保存添加
             if (ModelState.IsValid)
             {
                 Child_Book_Click addRecord = new Child_Book_Click();
                 addRecord.BookClassID   = model.BookClassID;
                 addRecord.BookName      = model.BookName;
                 addRecord.BookOnlineUrl = model.BookOnlineUrl;
                 addRecord.ScreenH       = model.ScreenH;
                 addRecord.OrderBy       = model.OrderBy;
                 addRecord.AddDate       = DateTime.Now;
                 addRecord.PraiceCount   = 0;
                 addRecord.ReadCount     = 0;
                 addRecord.BookStatus    = 200;
                 //
                 myOperating.Child_Book_Click.Add(addRecord);
                 myOperating.SaveChanges();
                 //
                 return(RedirectToLocal(ReturnUrl));
             }
             else
             {
                 ModelState.AddModelError("", "输入错误");
             }
             #endregion
         }
         else if (model.Operate == "edit")
         {
             //
             #region 保存编辑
             if (ModelState.IsValid)
             {
                 Child_Book_Click editSaveRecord = myOperating.Child_Book_Click.FirstOrDefault(p => p.BookID == model.BookID);
                 if (editSaveRecord != null)
                 {
                     editSaveRecord.BookClassID   = model.BookClassID;
                     editSaveRecord.BookName      = model.BookName;
                     editSaveRecord.BookOnlineUrl = model.BookOnlineUrl;
                     editSaveRecord.ScreenH       = model.ScreenH;
                     editSaveRecord.OrderBy       = model.OrderBy;
                     //
                     myOperating.SaveChanges();
                     //
                     return(RedirectToLocal(ReturnUrl));
                 }
             }
             else
             {
                 ModelState.AddModelError("", "输入错误");
             }
             #endregion
         }
         else
         {                                //初次加载-添加
             model.BookClassID = ClassId; //类别编号
             model.Operate     = "add";
             #region 默认值
             try
             {
                 if (ClassId != 0)
                 {
                     model.OrderBy = myOperating.Child_Book_Click.Where(p => p.BookClassID == ClassId).Max(p => p.OrderBy) + 1;
                 }
                 else
                 {
                     model.OrderBy = myOperating.Child_Book_Click.Max(p => p.OrderBy) + 1;
                 }
             }
             catch
             {
                 model.OrderBy = 0;
             }
             if (model.OrderBy == null)
             {
                 model.OrderBy = 1;
             }
             #endregion
         }
         #region 类别
         List <Child_Book_Click_Class> ClassTable = myOperating.Child_Book_Click_Class.Where(p => p.Status == 200).OrderByDescending(p => p.OrderBy).ToList();
         ViewBag.DataListClass = ClassTable;
         #endregion
     }
     //
     return(View(model));
 }
Example #5
0
        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));
        }
Example #6
0
        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));
        }
Example #7
0
        public JsonResult ReadBookDays(string bookid)
        {
            string mobilePhone = "";                    //
            //
            StatusData myStatusData = new StatusData(); //返回状态

            //
            #region 检查授权
            AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance();
            AuthCodeClass    myAuthCodeClass    = new AuthCodeClass();
            bool             checkAuthCodeBool  = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance);
            #endregion
            using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作
            {
                long myLong = 0;
                bool isLong = long.TryParse(bookid, out myLong);
                if (isLong)
                {
                    #region 图书阅读数加一
                    Child_Book_Click myChild_Book_Click = new Child_Book_Click();
                    myChild_Book_Click = myOperating.Child_Book_Click.FirstOrDefault(p => p.BookID == myLong);
                    if (myChild_Book_Click != null)
                    {
                        myChild_Book_Click.ReadCount = myChild_Book_Click.ReadCount + 1;
                    }
                    #endregion
                    //
                    #region 用户阅读天数
                    User_Book_Click_ReadDay myUser_Book_Click_ReadDay = new User_Book_Click_ReadDay();
                    if (checkAuthCodeBool)
                    {
                        DateTime myNowDate = DateTime.Parse(DateTime.Now.ToShortDateString());
                        mobilePhone = myAuthCodeInstance.mobilePhone;
                        //
                        myUser_Book_Click_ReadDay = myOperating.User_Book_Click_ReadDay.FirstOrDefault(p => p.MobilePhone == mobilePhone);
                        if (myUser_Book_Click_ReadDay != null)
                        {
                            if (myUser_Book_Click_ReadDay.UpdateDate == myNowDate.AddDays(-1))
                            {//昨天阅读过,连续
                                myUser_Book_Click_ReadDay.ReadDayCount       = myUser_Book_Click_ReadDay.ReadDayCount + 1;
                                myUser_Book_Click_ReadDay.RecentlyReadBookId = myLong;
                                myUser_Book_Click_ReadDay.Continuity         = myUser_Book_Click_ReadDay.Continuity + 1;
                                myUser_Book_Click_ReadDay.UpdateDate         = myNowDate;
                            }
                            else if (myUser_Book_Click_ReadDay.UpdateDate < myNowDate)
                            {//不连续
                                myUser_Book_Click_ReadDay.ReadDayCount       = myUser_Book_Click_ReadDay.ReadDayCount + 1;
                                myUser_Book_Click_ReadDay.RecentlyReadBookId = myLong;
                                myUser_Book_Click_ReadDay.Continuity         = 1;
                                myUser_Book_Click_ReadDay.UpdateDate         = myNowDate;
                            }
                        }
                        else
                        { //不存在则增加
                            User_Book_Click_ReadDay newUser_Book_Click_ReadDay = new User_Book_Click_ReadDay();
                            newUser_Book_Click_ReadDay.MobilePhone        = mobilePhone;
                            newUser_Book_Click_ReadDay.ReadDayCount       = 1;
                            newUser_Book_Click_ReadDay.RecentlyReadBookId = myLong;
                            newUser_Book_Click_ReadDay.Continuity         = 1;
                            newUser_Book_Click_ReadDay.UpdateDate         = myNowDate;
                            myOperating.User_Book_Click_ReadDay.Add(newUser_Book_Click_ReadDay);
                        }
                    }
                    #endregion
                    myOperating.SaveChanges();
                    myStatusData.operateStatus = 200;
                }
            }

            return(Json(myStatusData));
        }