public ActionResult Edit([Bind(Include = "Department_Lecturer_Id,Department_Id,Employee_Id,Created_By,Created_Date,Modified_By,Modified_Date")] Acd_Department_Lecturer acd_Department_Lecturer) { if (ModelState.IsValid) { db.Entry(acd_Department_Lecturer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Employee_Id = new SelectList(db.Emp_Employee, "Employee_Id", "Nik", acd_Department_Lecturer.Employee_Id); ViewBag.Department_Id = new SelectList(db.Mstr_Department.OrderBy(d => d.Department_Code), "Department_Id", "Department_Code", acd_Department_Lecturer.Department_Id); return(View(acd_Department_Lecturer)); }
// GET: DepartmentLecturer/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Acd_Department_Lecturer acd_Department_Lecturer = db.Acd_Department_Lecturer.Find(id); if (acd_Department_Lecturer == null) { return(HttpNotFound()); } return(View(acd_Department_Lecturer)); }
// GET: DepartmentLecturer/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Acd_Department_Lecturer acd_Department_Lecturer = db.Acd_Department_Lecturer.Find(id); if (acd_Department_Lecturer == null) { return(HttpNotFound()); } ViewBag.Employee_Id = new SelectList(db.Emp_Employee, "Employee_Id", "Nik", acd_Department_Lecturer.Employee_Id); ViewBag.Department_Id = new SelectList(db.Mstr_Department.OrderBy(d => d.Department_Code), "Department_Id", "Department_Code", acd_Department_Lecturer.Department_Id); return(View(acd_Department_Lecturer)); }
// GET: DepartmentLecturer/Delete/5 //public ActionResult Delete(int? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // Acd_Department_Lecturer acd_Department_Lecturer = db.Acd_Department_Lecturer.Find(id); // if (acd_Department_Lecturer == null) // { // return HttpNotFound(); // } // return View(acd_Department_Lecturer); //} // POST: DepartmentLecturer/Delete/5 //[HttpPost, ActionName("Delete")] //[ValidateAntiForgeryToken] public ActionResult Delete(int id) { Acd_Department_Lecturer acd_Department_Lecturer = db.Acd_Department_Lecturer.Find(id); db.Acd_Department_Lecturer.Remove(acd_Department_Lecturer); try { db.SaveChanges(); } catch (DbUpdateException) { TempData["gagalHapus"] = "Gagal Hapus, Data sudah digunakan"; return(Redirect(System.Web.HttpContext.Current.Request.UrlReferrer.ToString())); } TempData["berhasilHapus"] = "Berhasil Hapus Data."; //return RedirectToAction("Index"); return(Redirect(System.Web.HttpContext.Current.Request.UrlReferrer.ToString())); }
public ActionResult Create([Bind(Include = "Department_Lecturer_Id,Department_Id,Employee_Id,Created_By,Created_Date,Modified_By,Modified_Date")] Acd_Department_Lecturer acd_Department_Lecturer, int[] Employees) { string UrlReferrer = System.Web.HttpContext.Current.Request.UrlReferrer.ToString(); if (Employees == null) { TempData["shortMessage"] = "Anda Belum Memilih Dosen."; return(Redirect(UrlReferrer)); } if (ModelState.IsValid) { for (int i = 0; i < Employees.Length; i++) { acd_Department_Lecturer.Employee_Id = Employees[i]; db.Acd_Department_Lecturer.Add(acd_Department_Lecturer); db.SaveChanges(); } return(Redirect(UrlReferrer)); } //ViewBag.Employee_Id = new SelectList(db.Emp_Employee, "Employee_Id", "Nik", acd_Department_Lecturer.Employee_Id); //ViewBag.Department_Id = new SelectList(db.Mstr_Department, "Department_Id", "Department_Code", acd_Department_Lecturer.Department_Id); return(View(acd_Department_Lecturer)); }