public ActionResult Edit([Bind(Include = "Month_Id,Month_Code,Month_Name")] Mstr_Month mstr_Month) { if (ModelState.IsValid) { db.Entry(mstr_Month).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateException) { Mstr_Country country = db.Mstr_Country.Find(mstr_Month.Month_Id); if (country == null) { return(HttpNotFound()); } TempData["shortMessage"] = "Kode Bulan telah ada."; return(RedirectToAction("Edit", mstr_Month)); throw; } return(RedirectToAction("Index")); } return(View(mstr_Month)); }
public ActionResult Create([Bind(Include = "Month_Id,Month_Code,Month_Name")] Mstr_Month mstr_Month) { if (ModelState.IsValid) { db.Mstr_Month.Add(mstr_Month); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(mstr_Month)); }
// GET: Month/Details/5 public ActionResult Details(byte?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Mstr_Month mstr_Month = db.Mstr_Month.Find(id); if (mstr_Month == null) { return(HttpNotFound()); } return(View(mstr_Month)); }
// GET: Month/Delete/5 //public ActionResult Delete(byte? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // Mstr_Month mstr_Month = db.Mstr_Month.Find(id); // if (mstr_Month == null) // { // return HttpNotFound(); // } // return View(mstr_Month); //} // POST: Month/Delete/5 //[HttpPost, ActionName("Delete")] //[ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(byte id) { Mstr_Month mstr_Month = db.Mstr_Month.Find(id); db.Mstr_Month.Remove(mstr_Month); try { db.SaveChanges(); } catch (DbUpdateException) { TempData["gagalHapus"] = "Gagal Hapus, Data sudah digunakan"; return(RedirectToAction("Index")); } TempData["berhasilHapus"] = "Berhasil Hapus Data."; return(RedirectToAction("Index")); }
// GET: Month/Edit/5 public ActionResult Edit(byte?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (TempData["shortMessage"] != null) { ViewBag.message = TempData["shortMessage"].ToString(); } Mstr_Month mstr_Month = db.Mstr_Month.Find(id); if (mstr_Month == null) { return(HttpNotFound()); } return(View(mstr_Month)); }