public ActionResult Edit([Bind(Include = "Country_Id,Country_Code,Country_Name,Country_Acronym,Order_Id")] Mstr_Country mstr_Country) { if (ModelState.IsValid) { db.Entry(mstr_Country).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateException) { Mstr_Country country = db.Mstr_Country.Find(mstr_Country.Country_Id); if (country == null) { return(HttpNotFound()); } TempData["shortMessage"] = "Kode Negara telah ada."; return(RedirectToAction("Edit", mstr_Country)); throw; } return(RedirectToAction("Index")); } return(View(mstr_Country)); }
public ActionResult Edit([Bind(Include = "Blood_Type_Id,Blood_Code,Blood_Type,Order_Id")] Mstr_Blood_Type mstr_Blood_Type) { if (ModelState.IsValid) { db.Entry(mstr_Blood_Type).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateException) { Mstr_Country country = db.Mstr_Country.Find(mstr_Blood_Type.Blood_Type_Id); if (country == null) { return(HttpNotFound()); } TempData["shortMessage"] = "Kode Golongan Darah telah ada."; return(RedirectToAction("Edit", mstr_Blood_Type)); throw; } return(RedirectToAction("Index")); } return(View(mstr_Blood_Type)); }
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 = "Country_Id,Country_Code,Country_Name,Country_Acronym,Order_Id")] Mstr_Country mstr_Country) { if (ModelState.IsValid) { db.Mstr_Country.Add(mstr_Country); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(mstr_Country)); }
// GET: Country/Details/5 public ActionResult Details(short?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Mstr_Country mstr_Country = db.Mstr_Country.Find(id); if (mstr_Country == null) { return(HttpNotFound()); } return(View(mstr_Country)); }
// GET: Country/Delete/5 //public ActionResult Delete(short? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // Mstr_Country mstr_Country = db.Mstr_Country.Find(id); // if (mstr_Country == null) // { // return HttpNotFound(); // } // return View(mstr_Country); //} // POST: Country/Delete/5 //[HttpPost, ActionName("Delete")] //[ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(short id) { Mstr_Country mstr_Country = db.Mstr_Country.Find(id); db.Mstr_Country.Remove(mstr_Country); try { db.SaveChanges(); } catch (DbUpdateException) { TempData["gagalHapus"] = "Gagal Hapus, Data sudah digunakan"; return(RedirectToAction("Index")); } TempData["berhasilHapus"] = "Berhasil Hapus Data."; return(RedirectToAction("Index")); }
// GET: Country/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_Country mstr_Country = db.Mstr_Country.Find(id); if (mstr_Country == null) { return(HttpNotFound()); } return(View(mstr_Country)); }