Example #1
0
 public ActionResult Edit(Contact contact)
 {
     if (ModelState.IsValid)
     {
         _context.Contacts.Attach(contact);
         _context.ObjectStateManager.ChangeObjectState(contact, EntityState.Modified);
         _context.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(contact);
 }
Example #2
0
        public ActionResult Create()
        {
            Contact contact = new Contact();
            contact.Name = RandomString(6);
            contact.Phone = RandomPhone();
            contact.CreatedDate = DateTime.Now;

              _context.Contacts.AddObject(contact);
              _context.SaveChanges();

            return RedirectToAction("Index");
        }
 /// <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);
 }
 /// <summary>
 /// Create a new Contact object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="createdDate">Initial value of the CreatedDate property.</param>
 public static Contact CreateContact(global::System.Int64 id, global::System.String name, global::System.DateTime createdDate)
 {
     Contact contact = new Contact();
     contact.Id = id;
     contact.Name = name;
     contact.CreatedDate = createdDate;
     return contact;
 }