public ActionResult AddContact(Contact contact) { if (ModelState.IsValid) { using (ApplicationDbContext db = new ApplicationDbContext()) { db.Contacts.Add(contact); db.SaveChanges(); } } return RedirectToAction("ResourceDetails", new { id = contact.ResourceId }); }
public ActionResult EditContact(Contact contact) { if (ModelState.IsValid) { using (ApplicationDbContext db = new ApplicationDbContext()) { db.Entry(contact).State = EntityState.Modified; db.SaveChanges(); } } return RedirectToAction("ResourceDetails", new { id = contact.ResourceId }); }
public ActionResult AddContact(int id) { Contact contact = new Contact(); contact = new Contact() { ResourceId = id }; return View(contact); }
public ActionResult EditContact(int id) { Contact contact = new Contact(); using (ApplicationDbContext db = new ApplicationDbContext()) { contact = db.Contacts.Where(x => x.ContactId == id).FirstOrDefault(); } return View(contact); }