Esempio n. 1
0
        public IActionResult Getlevel(int id = 0)
        {
            var model = new ViewLevel();

            if (id > 0)
            {
                model = _viewLevel.FindById(id);
            }


            return(Json(model));
        }
Esempio n. 2
0
        public IActionResult Remove(int id = 0)
        { //TODO : Refactoring Unit of Work
            var lessonid = 0;

            if (id > 0)
            {
                var  removeSubject        = _subject.FindById(id);
                bool viewlevelChangeState = false;
                lessonid = removeSubject.Lessonid;
                _subject.Remove(removeSubject);
                var getlist = _content.GetList(x => x.Subjectid == id).Result;
                getlist.ForEach(x =>
                {
                    var removeContent = _content.FindById(x.id);
                    _content.Remove(removeContent);
                    if (_viewLevel.GetList(v => v.Contentid == x.id).Result.Count > 0)
                    {
                        _viewLevel.GetList(v => v.Contentid == x.id).Result.ForEach(f =>
                        {
                            var removeLevel = _viewLevel.FindById(f.id);
                            _viewLevel.Remove(removeLevel);
                            viewlevelChangeState = true;
                        });
                    }
                });

                if (viewlevelChangeState)
                {
                    _viewLevel.Save();
                }
                ;

                _content.Save();
                _subject.Save();
            }

            return(RedirectToAction("subjectlist", "lesson", new { id = lessonid }));
        }