public List <AllergyType> getAllergyTypes() { List <AllergyType> allergyTypes = new List <AllergyType>(); using (SqlConnection conn = new SqlConnection(this.connectionString)) { conn.Open(); const string sql = @"SELECT * FROM allergy_type;"; SqlCommand cmd = new SqlCommand(sql, conn); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { AllergyType allergyType = new AllergyType(); allergyType.AllergyTypeId = Convert.ToInt32(rdr["allergy_type_id"]); allergyType.Name = Convert.ToString(rdr["name"]); allergyTypes.Add(allergyType); } } return(allergyTypes); }
public ActionResult DeleteConfirmed(int id) { AllergyType allergyType = db.AllergyTypes.Find(id); db.AllergyTypes.Remove(allergyType); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "AllergyTypeID,AllergyTypeName")] AllergyType allergyType) { if (ModelState.IsValid) { db.Entry(allergyType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(allergyType)); }
public ActionResult Create([Bind(Include = "AllergyTypeID,AllergyTypeName")] AllergyType allergyType) { if (ModelState.IsValid) { db.AllergyTypes.Add(allergyType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(allergyType)); }
// GET: AllergyTypes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AllergyType allergyType = db.AllergyTypes.Find(id); if (allergyType == null) { return(HttpNotFound()); } return(View(allergyType)); }