// GET: Address/Create public ActionResult Create(int id) { ViewBag.id = id; IEnumerable <SelectListItem> countries = db.Countries.Select(c => new SelectListItem() { Value = c.country_id.ToString(), Text = c.country_name }); ViewBag.countries = countries; Models.PersonInformation person = db.PersonInformations.SingleOrDefault(c => c.person_id == id); return(View()); }
public ActionResult Edit(int id, FormCollection collection) { try { Models.PersonInformation thePerson = db.PersonInformations.SingleOrDefault(p => p.person_id == id); thePerson.first_name = collection["first_name"]; thePerson.last_name = collection["last_name"]; thePerson.notes = collection["notes"]; thePerson.gender = collection["gender"]; thePerson.profile_picture = 0; db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(FormCollection collection) { try { Models.PersonInformation newPerson = new Models.PersonInformation(); newPerson.first_name = collection["first_name"]; newPerson.last_name = collection["last_name"]; newPerson.notes = collection["notes"]; newPerson.gender = collection["gender"]; newPerson.profile_picture = 0; db.PersonInformations.Add(newPerson); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { try { // TODO: Add delete logic here Models.PersonInformation thePerson = db.PersonInformations.SingleOrDefault(p => p.person_id == id); db.Addresses.RemoveRange(thePerson.Addresses); db.Pictures.RemoveRange(thePerson.Pictures); thePerson.profile_picture = null; db.ContactInformations.RemoveRange(thePerson.ContactInformations); db.SaveChanges(); db.PersonInformations.Remove(thePerson); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: Home/Delete/5 public ActionResult Delete(int id) { Models.PersonInformation thePerson = db.PersonInformations.SingleOrDefault(p => p.person_id == id); return(View(thePerson)); }
// GET: Contact/Create public ActionResult Create(int id) { ViewBag.id = id; Models.PersonInformation person = db.PersonInformations.SingleOrDefault(c => c.person_id == id); return(View()); }