public async Task <IActionResult> EditSubject(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            Subject subject = await _db.Subjects.Include(c => c.Course).Where(c => c.Id == id && c.isDeleted == true).FirstOrDefaultAsync();

            if (subject == null)
            {
                return(NotFound());
            }
            if (subject.isDeleted == false)
            {
                return(NotFound());
            }

            Article article = await _db.Articles.Include(a => a.Subject).Include(a => a.User).Where(a => a.SubjectId == subject.Id).FirstOrDefaultAsync();

            List <EditedSubject> editedSubjects = _db.EditedSubjects.Include(a => a.User).Where(e => e.SubjectId == subject.Id).ToList();

            EditedSubjectVM subjectVM = new EditedSubjectVM
            {
                Courses        = _db.Courses.Where(c => c.isDeleted == false),
                Article        = article,
                Subject        = subject,
                EditedSubjects = editedSubjects
            };

            return(View(subjectVM));
        }
        public async Task <IActionResult> EditSubject(int?id, ArticleVM articleVM)
        {
            if (id == null)
            {
                return(NotFound());
            }
            Subject subject = await _db.Subjects.Include(s => s.Course).Where(s => s.Id == id && s.isDeleted == true).FirstOrDefaultAsync();

            if (subject == null)
            {
                return(NotFound());
            }
            if (subject.isDeleted == false)
            {
                return(NotFound());
            }

            Article article = await _db.Articles.Include(a => a.Subject).Include(a => a.User).Where(a => a.SubjectId == subject.Id).FirstOrDefaultAsync();

            List <EditedSubject> editedSubjects = _db.EditedSubjects.Include(a => a.User).Where(e => e.SubjectId == subject.Id).ToList();

            EditedSubjectVM subjectVM = new EditedSubjectVM
            {
                Courses        = _db.Courses.Where(c => c.isDeleted == false),
                Article        = article,
                Subject        = subject,
                EditedSubjects = editedSubjects
            };

            if (!ModelState.IsValid)
            {
                return(View(subjectVM));
            }

            User user = await _userManager.GetUserAsync(User);

            subject.Name       = articleVM.Subject.Name;
            subject.Definition = articleVM.Subject.Definition;

            article.Content = articleVM.Article.Content;
            Course course = await _db.Courses.FindAsync(Int32.Parse(Request.Form["course"]));

            int           prev_id       = subject.CourseId;
            EditedSubject editedSubject = new EditedSubject
            {
                SubjectId  = subject.Id,
                UserId     = user.Id,
                EditedDate = DateTime.Now
            };

            subject.Course = course;
            _db.EditedSubjects.Add(editedSubject);
            await _db.SaveChangesAsync();

            return(RedirectToAction("Subject"));
        }