public ActionResult Create([Bind(Include = "Course_Identic_Id,Identic_Name,Department_Id,Created_By,Created_Date,Modified_By,Modified_Date")] Acd_Course_Identic acd_Course_Identic, int[] Courses, string UrlReferrer)
        {
            Acd_Course_Identic_Detail acd_Course_Identic_Detail = new Acd_Course_Identic_Detail();

            if (ModelState.IsValid)
            {
                db.Acd_Course_Identic.Add(acd_Course_Identic);
                db.SaveChanges();
                if (Courses != null)
                {
                    short Course_Identic_Id = db.Acd_Course_Identic.Where(ci => ci.Identic_Name == acd_Course_Identic.Identic_Name).Select(ci => ci.Course_Identic_Id).First();
                    for (int i = 0; i < Courses.Length; i++)
                    {
                        acd_Course_Identic_Detail.Course_Identic_Id = Course_Identic_Id;
                        acd_Course_Identic_Detail.Course_Id         = Courses[i];
                        db.Acd_Course_Identic_Detail.Add(acd_Course_Identic_Detail);
                        db.SaveChanges();
                    }
                }

                return(Redirect(UrlReferrer));
            }

            List <int> exceptionList = db.Acd_Course_Identic_Detail.Select(cid => cid.Course_Id).ToList();

            ViewBag.Course_Id     = new SelectList(db.Acd_Course.Where(c => !exceptionList.Contains(c.Course_Id)), "Course_Id", "NameCode");
            ViewBag.Department_Id = acd_Course_Identic.Department_Id;

            return(View(acd_Course_Identic));
        }
        // GET: CourseIdentic/Edit/5
        public ActionResult Edit(short?id, string UrlReferrer)
        {
            if (TempData["gagalHapus"] != null)
            {
                ViewBag.gagalHapus = TempData["gagalHapus"].ToString();
            }
            if (TempData["berhasilHapus"] != null)
            {
                ViewBag.berhasilHapus = TempData["berhasilHapus"].ToString();
            }
            ViewBag.UrlReferrer = UrlReferrer ?? System.Web.HttpContext.Current.Request.UrlReferrer.ToString();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Acd_Course_Identic acd_Course_Identic = db.Acd_Course_Identic.Find(id);

            if (acd_Course_Identic == null)
            {
                return(HttpNotFound());
            }

            ViewBag.acd_Course_Identic_Detail = db.Acd_Course_Identic_Detail.Where(cid => cid.Course_Identic_Id == acd_Course_Identic.Course_Identic_Id);

            List <int> exceptionList = db.Acd_Course_Identic_Detail.Select(cid => cid.Course_Id).ToList();

            ViewBag.Course_Id = new SelectList(db.Acd_Course.Where(c => !exceptionList.Contains(c.Course_Id)), "Course_Id", "NameCode");
            //ViewBag.Department = db.Mstr_Department.Where(d => d.Department_Id == acd_Course_Identic.Department_Id).First();
            return(View(acd_Course_Identic));
        }
        // GET: CourseIdentic/Details/5
        public ActionResult Details(short?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Acd_Course_Identic acd_Course_Identic = db.Acd_Course_Identic.Find(id);

            if (acd_Course_Identic == null)
            {
                return(HttpNotFound());
            }
            return(View(acd_Course_Identic));
        }
        //// GET: CourseIdentic/Delete/5
        //public ActionResult Delete(short? id)
        //{
        //    if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    Acd_Course_Identic acd_Course_Identic = db.Acd_Course_Identic.Find(id);
        //    if (acd_Course_Identic == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return View(acd_Course_Identic);
        //}

        //// POST: CourseIdentic/Delete/5
        //[HttpPost, ActionName("Delete")]
        //[ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(short id)
        {
            string             UrlReferrer        = System.Web.HttpContext.Current.Request.UrlReferrer.ToString();
            Acd_Course_Identic acd_Course_Identic = db.Acd_Course_Identic.Find(id);

            db.Acd_Course_Identic.Remove(acd_Course_Identic);
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                TempData["gagalHapus"] = "Gagal Hapus, Data sudah digunakan";
                return(Redirect(UrlReferrer));
            }
            TempData["berhasilHapus"] = "Berhasil Hapus Data.";
            return(Redirect(UrlReferrer));
        }