Ejemplo n.º 1
0
        /// <summary>
        /// 取消踩
        /// </summary>
        /// <param name="target_id"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public static bool AbortNotLike(int target_id, int optionType)
        {
            ZZULIEntities ef  = GetEntity();
            bool          res = false;

            switch (optionType)
            {
            case 18:    //课程
                var course = ef.Courses.Where(c => c.Cou_ID == target_id).FirstOrDefault();
                course.Cou_NotLikes--;
                if (ef.SaveChanges() > 0)
                {
                    ef.SP_UpdateCourseHotByCou_ID(target_id);
                    res = true;
                }
                break;

            case 19:    //问题回复
                var answer = ef.Answers.Where(a => a.A_ID == target_id).FirstOrDefault();
                answer.A_NotLikes--;
                if (ef.SaveChanges() > 0)
                {
                    ef.SP_UpdateQuestionHotByQ_ID(target_id);
                    res = true;
                }
                break;

            case 20:    //笔记
                var note = ef.Notes.Where(n => n.N_ID == target_id).FirstOrDefault();
                note.N_NotLikes--;
                if (ef.SaveChanges() > 0)
                {
                    ef.SP_UpdateNoteHotByN_ID(target_id);
                    res = true;
                }
                break;

            default:
                res = false;
                break;
            }
            return(res);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 取消点赞
        /// </summary>
        /// <param name="target_id"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public static bool AbortLike(int target_id, int optionType)
        {
            ZZULIEntities ef  = GetEntity();
            bool          res = false;

            switch (optionType)
            {
            case 11:    //课程
                var course = ef.Courses.Where(cou => cou.Cou_ID == target_id).FirstOrDefault();
                course.Cou_Likes--;
                if (ef.SaveChanges() > 0)
                {
                    ef.SP_UpdateCourseHotByCou_ID(target_id);
                    res = true;
                }
                break;

            case 12:    //课程评论
                var ccom = ef.CoursesComment.Where(cc => cc.CCom_ID == target_id).FirstOrDefault();
                ccom.CCom_Likes--;
                if (ef.SaveChanges() > 0)
                {
                    ef.SP_UpdateCourseHotByCou_ID(target_id);
                    res = true;
                }
                break;

            case 13:    //课程问题回复
                var couA = ef.CoursesAnswers.Where(ca => ca.CA_ID == target_id).FirstOrDefault();
                couA.CA_Likes--;
                if (ef.SaveChanges() > 0)
                {
                    ef.SP_UpdateCourseQuestionHot(target_id);
                    res = true;
                }
                break;

            case 14:    //课程笔记
                var couN = ef.CoursesNotes.Where(cn => cn.CN_ID == target_id).FirstOrDefault();
                couN.CN_Likes--;
                if (ef.SaveChanges() > 0)
                {
                    ef.SP_UpdateCourseNoteHot(target_id);
                    res = true;
                }
                break;

            case 15:    //问题回复
                var answer = ef.Answers.Where(a => a.A_ID == target_id).FirstOrDefault();
                answer.A_Likes--;
                if (ef.SaveChanges() > 0)
                {
                    ef.SP_UpdateQuestionHotByQ_ID(target_id);
                    res = true;
                }
                break;

            case 16:    //笔记
                var note = ef.Notes.Where(n => n.N_ID == target_id).FirstOrDefault();
                note.N_Likes--;
                if (ef.SaveChanges() > 0)
                {
                    ef.SP_UpdateNoteHotByN_ID(target_id);
                    res = true;
                }
                break;

            case 17:    //笔记评论
                var ncom = ef.NotesComments.Where(nc => nc.NC_ID == target_id).FirstOrDefault();
                ncom.NC_Likes--;
                if (ef.SaveChanges() > 0)
                {
                    ef.SP_UpdateNoteHotByN_ID(target_id);
                    res = true;
                }
                break;

            default:
                break;
            }
            return(res);
        }