示例#1
0
        private SyncResponse DeletePreLessonResource(SyncRequest request)
        {
            PreLessonContent preLessonContent = new PreLessonContent();
            clr_preLesson    submitData       = JsonHelper.DecodeJson <clr_preLesson>(request.Data);
            PreLessonBtn     submitDataBtn    = JsonHelper.DecodeJson <PreLessonBtn>(request.Data);

            using (var db = new fz_wisdomcampusEntities())
            {
                List <clr_preLesson> prelessonList = db.clr_preLesson.Where(p => p.UserID == submitData.UserID).ToList();
                foreach (var prelesson in prelessonList)
                {
                    preLessonContent = JsonHelper.DecodeJson <PreLessonContent>(prelesson.PreLessonContent);
                    for (int i = preLessonContent.btns.Count - 1; i >= 0; i--)
                    {
                        if (submitDataBtn.sourceUrl.IndexOf(preLessonContent.btns[i].sourceUrl) != -1)
                        {
                            preLessonContent.btns.Remove(preLessonContent.btns[i]);
                        }
                    }
                    string jsonContent = JsonHelper.DeepEncodeJson(preLessonContent);
                    prelesson.PreLessonContent = jsonContent;
                    prelesson.CreateDate       = DateTime.Now;
                    db.SaveChanges();
                }
                return(SyncResponse.GetResponse(request, true));
            }
        }
示例#2
0
        private SyncResponse DeletePreLesson(SyncRequest request)
        {
            PreLessonContent preLessonContent = new PreLessonContent();
            clr_preLesson    submitData       = JsonHelper.DecodeJson <clr_preLesson>(request.Data);

            using (var db = new fz_wisdomcampusEntities())
            {
                List <clr_preLesson> prelessonList = db.clr_preLesson.Where(p => p.UserID == submitData.UserID).ToList();
                foreach (var prelesson in prelessonList)
                {
                    db.clr_preLesson.Remove(prelesson);
                    db.SaveChanges();
                }
                return(SyncResponse.GetResponse(request, true));
            }
        }