예제 #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);
 }
예제 #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");
        }
예제 #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);
 }
예제 #4
0
 /// <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;
 }