Exemplo n.º 1
0
 public void Update(Contact contact)
 {
     using (ContactDbEntities db = new ContactDbEntities())
     {
         db.Contacts.Attach(contact);
         db.Entry(contact).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public ActionResult Edit(contactDb contactdb)
 {
     if (ModelState.IsValid)
     {
         db.Entry(contactdb).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(contactdb));
 }
        public void DeleteContactDAL(int id)
        {
            using (var ctx = new ContactDbEntities())
            {
                var contact = ctx.Contacts
                              .Where(s => s.Id == id)
                              .FirstOrDefault();

                ctx.Entry(contact).State = System.Data.EntityState.Deleted;
                ctx.SaveChanges();
            }
        }