public ActionResult Edit([Bind(Include = "Department_Id,Department_Code,Faculty_Id,Department_Name,Department_Name_Eng,Department_Acronym,Department_Dikti_Sk_Number,Department_Dikti_Sk_Date,Order_Id,Education_Prog_Type_Id,Created_By,Created_Date,Modified_By,Modified_Date")] Mstr_Department mstr_Department) { if (ModelState.IsValid) { db.Entry(mstr_Department).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateException) { Mstr_Department department = db.Mstr_Department.Find(mstr_Department.Department_Id); if (department == null) { return(HttpNotFound()); } TempData["shortMessage"] = "Kode Departemen telah ada."; return(RedirectToAction("Edit", new { id = mstr_Department.Department_Id })); throw; } return(RedirectToAction("Index", new { Faculty_Id = mstr_Department.Faculty_Id })); } ViewBag.Faculty_Id = new SelectList(db.Mstr_Faculty, "Faculty_Id", "Faculty_Name", mstr_Department.Faculty_Id); return(View(mstr_Department)); }
public ActionResult Create([Bind(Include = "Department_Id,Department_Code,Faculty_Id,Department_Name,Department_Name_Eng,Department_Acronym,Department_Dikti_Sk_Number,Department_Dikti_Sk_Date,Order_Id,Education_Prog_Type_Id,Created_By,Created_Date,Modified_By,Modified_Date")] Mstr_Department mstr_Department) { if (ModelState.IsValid) { db.Mstr_Department.Add(mstr_Department); db.SaveChanges(); return(RedirectToAction("Index", new { Faculty_Id = mstr_Department.Faculty_Id })); } ViewBag.Faculty = db.Mstr_Faculty.Where(f => f.Faculty_Id == mstr_Department.Faculty_Id).FirstOrDefault(); ViewBag.Education_Prog_Type_Id = new SelectList(db.Mstr_Education_Program_Type, "Education_Prog_Type_Id", "Program_Name", mstr_Department.Education_Prog_Type_Id); return(View(mstr_Department)); }
// GET: Department/Details/5 public ActionResult Details(short?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Mstr_Department mstr_Department = db.Mstr_Department.Find(id); if (mstr_Department == null) { return(HttpNotFound()); } return(View(mstr_Department)); }
// GET: Department/Delete/5 //public ActionResult Delete(short? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // Mstr_Department mstr_Department = db.Mstr_Department.Find(id); // if (mstr_Department == null) // { // return HttpNotFound(); // } // return View(mstr_Department); //} // POST: Department/Delete/5 //[HttpPost, ActionName("Delete")] //[ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(short id) { string UrlReferrer = System.Web.HttpContext.Current.Request.UrlReferrer.ToString(); Mstr_Department mstr_Department = db.Mstr_Department.Find(id); db.Mstr_Department.Remove(mstr_Department); try { db.SaveChanges(); } catch (DbUpdateException) { TempData["gagalHapus"] = "Gagal Hapus, Data sudah digunakan"; return(Redirect(UrlReferrer)); } TempData["berhasilHapus"] = "Berhasil Hapus Data."; return(Redirect(UrlReferrer)); }
// GET: Department/Edit/5 public ActionResult Edit(short?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (TempData["shortMessage"] != null) { ViewBag.message = TempData["shortMessage"].ToString(); } Mstr_Department mstr_Department = db.Mstr_Department.Find(id); if (mstr_Department == null) { return(HttpNotFound()); } ViewBag.Faculty_Id = new SelectList(db.Mstr_Faculty, "Faculty_Id", "Faculty_Name", mstr_Department.Faculty_Id); ViewBag.Education_Prog_Type_Id = new SelectList(db.Mstr_Education_Program_Type, "Education_Prog_Type_Id", "Program_Name", mstr_Department.Education_Prog_Type_Id); return(View(mstr_Department)); }