Ejemplo 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);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Create a new Contact object.
 /// </summary>
 /// <param name="contactId">Initial value of the ContactId property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 public static Contact CreateContact(global::System.Int32 contactId, global::System.String email)
 {
     Contact contact = new Contact();
     contact.ContactId = contactId;
     contact.Email = email;
     return contact;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Contacts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToContacts(Contact contact)
 {
     base.AddObject("Contacts", contact);
 }