public ActionResult DeleteConfirmed(string id) { Pest_Symptom pest_Symptom = db.Pest_Symptoms.Find(id); db.Pest_Symptoms.Remove(pest_Symptom); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "PS_ID,P_ID,S_ID,Part_ID")] Pest_Symptom pest_Symptom) { if (ModelState.IsValid) { db.Entry(pest_Symptom).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Part_ID = new SelectList(db.Parts, "Part_ID", "Name", pest_Symptom.Part_ID); ViewBag.P_ID = new SelectList(db.Pests, "P_ID", "Name", pest_Symptom.P_ID); ViewBag.S_ID = new SelectList(db.Symptoms, "S_ID", "Description", pest_Symptom.S_ID); return(View(pest_Symptom)); }
// GET: Pest_Symptom/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Pest_Symptom pest_Symptom = db.Pest_Symptoms.Find(id); if (pest_Symptom == null) { return(HttpNotFound()); } return(View(pest_Symptom)); }
// GET: Pest_Symptom/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Pest_Symptom pest_Symptom = db.Pest_Symptoms.Find(id); if (pest_Symptom == null) { return(HttpNotFound()); } ViewBag.Part_ID = new SelectList(db.Parts, "Part_ID", "Name", pest_Symptom.Part_ID); ViewBag.P_ID = new SelectList(db.Pests, "P_ID", "Name", pest_Symptom.P_ID); ViewBag.S_ID = new SelectList(db.Symptoms, "S_ID", "Description", pest_Symptom.S_ID); return(View(pest_Symptom)); }
public ActionResult Create([Bind(Include = "PS_ID,P_ID,S_ID,Part_ID")] Pest_Symptom pest_Symptom) { var query = db.Pest_Symptoms.Count() + 1; string temp = "PSY-" + query; bool exist = false; try { var search = db.Pest_Symptoms.Where(c => c.PS_ID == temp).Single(); exist = true; } catch { exist = false; } if (exist) { var all = db.Pest_Symptoms.ToList(); var dis = all.Last(); pest_Symptom.PS_ID = "PSY-" + DataModel.Constants.NextNumber(dis.PS_ID); } else { pest_Symptom.PS_ID = temp; } if (ModelState.IsValid) { db.Pest_Symptoms.Add(pest_Symptom); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Part_ID = new SelectList(db.Parts, "Part_ID", "Name", pest_Symptom.Part_ID); ViewBag.P_ID = new SelectList(db.Pests, "P_ID", "Name", pest_Symptom.P_ID); ViewBag.S_ID = new SelectList(db.Symptoms, "S_ID", "Description", pest_Symptom.S_ID); return(View(pest_Symptom)); }