Esempio n. 1
0
 public ActionResult Delete(int id, Contact contact)
 {
     try
     {
         using (var db = new ContactEntities())
         {
             db.Entry(db.Contacts.Find(id)).State = EntityState.Deleted;
             db.SaveChanges();
             return RedirectToAction("Index");
         }
     }
     catch
     {
         return View();
     }
 }
Esempio n. 2
0
 public ActionResult Create(Contact contact)
 {
     try
     {
         using (var db = new ContactEntities())
         {
             contact.Text = HttpUtility.UrlDecode(contact.Text, System.Text.Encoding.Default);
             db.Contacts.Add(contact);
             db.SaveChanges();
         }
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Esempio n. 3
0
 public ActionResult Edit(int id, Contact contact)
 {
     try
     {
         using (var db = new ContactEntities())
         {
             contact.Text = HttpUtility.UrlDecode(contact.Text, System.Text.Encoding.Default);
             db.Entry(contact).State = EntityState.Modified;
             db.SaveChanges();
             return RedirectToAction("Index");
         }
     }
     catch
     {
         return View();
     }
 }