示例#1
0
        public IHttpActionResult PutUser_Collect(long id, User_Collect user_Collect)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != user_Collect.ID)
            {
                return(BadRequest());
            }

            db.Entry(user_Collect).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!User_CollectExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public ActionResult DeleteConfirmed(long id)
        {
            User_Collect user_Collect = db.User_Collect.Find(id);

            db.User_Collect.Remove(user_Collect);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#3
0
        public IHttpActionResult GetUser_Collect(long id)
        {
            User_Collect user_Collect = db.User_Collect.Find(id);

            if (user_Collect == null)
            {
                return(NotFound());
            }

            return(Ok(user_Collect));
        }
示例#4
0
 public ActionResult Edit([Bind(Include = "ID,HouseID,UserID,CollectDate,OrderID,Status")] User_Collect user_Collect)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user_Collect).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.HouseID = new SelectList(db.Project_House, "ID", "UnitName", user_Collect.HouseID);
     ViewBag.UserID  = new SelectList(db.System_User, "ID", "UserName", user_Collect.UserID);
     return(View(user_Collect));
 }
示例#5
0
        public IHttpActionResult PostUser_Collect(User_Collect user_Collect)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.User_Collect.Add(user_Collect);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = user_Collect.ID }, user_Collect));
        }
示例#6
0
        // GET: Collect/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            User_Collect user_Collect = db.User_Collect.Find(id);

            if (user_Collect == null)
            {
                return(HttpNotFound());
            }
            return(View(user_Collect));
        }
示例#7
0
        public IHttpActionResult DeleteUser_Collect(long id)
        {
            User_Collect user_Collect = db.User_Collect.Find(id);

            if (user_Collect == null)
            {
                return(NotFound());
            }

            db.User_Collect.Remove(user_Collect);
            db.SaveChanges();

            return(Ok(user_Collect));
        }
示例#8
0
        // GET: Collect/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            User_Collect user_Collect = db.User_Collect.Find(id);

            if (user_Collect == null)
            {
                return(HttpNotFound());
            }
            ViewBag.HouseID = new SelectList(db.Project_House, "ID", "UnitName", user_Collect.HouseID);
            ViewBag.UserID  = new SelectList(db.System_User, "ID", "UserName", user_Collect.UserID);
            return(View(user_Collect));
        }
示例#9
0
 public JsonResult DelCollectItem(string collectid)
 {
     #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;
         try
         {
             using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities()) //数据库操作
             {
                 long         myLong         = 0;                                  //
                 bool         isLong         = long.TryParse(collectid, out myLong);
                 User_Collect myUser_Collect = new User_Collect();
                 myUser_Collect = myOperating.User_Collect.FirstOrDefault(p => p.MobilePhone == myMobilePhone && p.CollectId == myLong);;
                 //
                 if (myUser_Collect != null)
                 {
                     myOperating.User_Collect.Remove(myUser_Collect);
                     //
                     myOperating.SaveChanges();
                     //
                     myStatusData.operateStatus = 200;
                 }
             }
         }
         catch
         {
             myStatusData.operateStatus = -1;
         }
     }
     else
     {
         myStatusData.operateStatus = 5;
     }
     return(Json(myStatusData));
 }
示例#10
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);
        }
示例#11
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));
        }