예제 #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();
     }
 }
예제 #2
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();
     }
 }