public ActionResult DeleteConfirmed(int id) { EquipmentRarities equipmentRarities = db.EquipmentRarities.Find(id); db.EquipmentRarities.Remove(equipmentRarities); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: EquipmentRarities/Edit/5 // Attēlot ekipējuma retuma rediģēšanas skatu // Funkcija ER.06 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EquipmentRarities equipmentRarities = db.EquipmentRarities.Find(id); if (equipmentRarities == null) { return(HttpNotFound()); } return(View(equipmentRarities)); }
public ActionResult Edit([Bind(Include = "ID,Rarity")] EquipmentRarities equipmentRarities) { if (ModelState.IsValid) { var exists = db.EquipmentRarities.Any(e => e.Rarity == equipmentRarities.Rarity); if (exists) { ViewBag.Exists = "Rarity already exists in the database."; return(View(equipmentRarities)); } // Atrod un rediģē ierakstu datu bāzē ar jaunajiem datiem db.Entry(equipmentRarities).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(equipmentRarities)); }
public ActionResult Create([Bind(Include = "ID,Rarity")] EquipmentRarities equipmentRarities) { ViewBag.Exists = ""; if (ModelState.IsValid) { // Pārbauda, vai jau eksistē tāds datu bāzē var exists = db.EquipmentRarities.Any(e => e.Rarity == equipmentRarities.Rarity); if (exists) { ViewBag.Exists = "Rarity already exists in the database."; return(View(equipmentRarities)); } db.EquipmentRarities.Add(equipmentRarities); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(equipmentRarities)); }