Exemplo n.º 1
0
        public ActionResult Edit(Contact contact)
        {
            Contact update = null;
            int status = 0;
            using (var db = new SBSVEntities())
            {
                db.ContextOptions.LazyLoadingEnabled = false;

                update = (from c in db.Contacts
                          where c.ContactId == contact.ContactId
                          select c).FirstOrDefault();
            }
            if (update != null)
            {
                update = contact;
                using (var db = new SBSVEntities())
                {
                    db.Contacts.Attach(update);
                    db.ObjectStateManager.ChangeObjectState(update, System.Data.EntityState.Modified);
                    status = db.SaveChanges();
                }

            }

            if (status == 1)
            {
                ViewBag.Message = "data saved";
                return View(contact);
            }
            else
                return View(contact);
        }
Exemplo n.º 2
0
        //
        // GET: /Student/

        public ActionResult Index()
        {
            IEnumerable<Contact> contacts;
            using (var db = new SBSVEntities())
            {
                contacts = (from c in db.Contacts
                            select c).ToList();
            }
            return View(contacts);
        }
Exemplo n.º 3
0
 // GET api/values
 public IEnumerable<Contact> Get()
 {
     IEnumerable<Contact> contacts;
     using (var db = new SBSVEntities())
     {
         contacts = (from c in db.Contacts
                     select c).ToList();
     }
     return contacts;
 }
Exemplo n.º 4
0
 public ActionResult Edit(int id)
 {
     Contact contact;
     using (var db = new SBSVEntities())
     {
         contact = (from c in db.Contacts
                    where c.ContactId == id
                    select c).FirstOrDefault();
     }
     return View(contact);
 }