public ActionResult Create(ClassSubjectTable classSubjectTable)
        {
            if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"])))
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (ModelState.IsValid)
            {
                var classname = db.ClassTables.Where(c => c.ClassID == classSubjectTable.ClassID).SingleOrDefault();
                if (classname != null)
                {
                    if (!classSubjectTable.Name.Contains(classname.Name))
                    {
                        classSubjectTable.Name = classSubjectTable.Name + "-" + classname.Name;
                    }
                }

                db.ClassSubjectTables.Add(classSubjectTable);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ClassID   = new SelectList(db.ClassTables.Where(c => c.IsActive == true), "ClassID", "Name", classSubjectTable.ClassID);
            ViewBag.SubjectID = new SelectList(db.SubjectTables, "SubjectID", "Name", classSubjectTable.SubjectID);
            return(View(classSubjectTable));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"])))
            {
                return(RedirectToAction("Login", "Home"));
            }
            ClassSubjectTable classSubjectTable = db.ClassSubjectTables.Find(id);

            db.ClassSubjectTables.Remove(classSubjectTable);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: ClassSubjectTables/Details/5
        public ActionResult Details(int?id)
        {
            if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"])))
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ClassSubjectTable classSubjectTable = db.ClassSubjectTables.Find(id);

            if (classSubjectTable == null)
            {
                return(HttpNotFound());
            }
            return(View(classSubjectTable));
        }
        // GET: ClassSubjectTables/Edit/5
        public ActionResult Edit(int?id)
        {
            if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"])))
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ClassSubjectTable classSubjectTable = db.ClassSubjectTables.Find(id);

            if (classSubjectTable == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ClassID   = new SelectList(db.ClassTables.Where(c => c.IsActive == true), "ClassID", "Name", classSubjectTable.ClassID);
            ViewBag.SubjectID = new SelectList(db.SubjectTables, "SubjectID", "Name", classSubjectTable.SubjectID);
            return(View(classSubjectTable));
        }