//public ActionResult Edit() //{ // int contactID = int.Parse(RouteData.Values["id"].ToString()); // var database = new FakeContactDatabase(); // var contact = database.GetById(contactID); // return View(contact); //} public ActionResult Edit(int id) { var database = new FakeContactDatabase(); var contact = database.GetById(id); return(View(contact)); }
public ActionResult AddContact(Contact contact) { var database = new FakeContactDatabase(); database.Add(contact); return(RedirectToAction("Index")); }
// GET: Home public ActionResult Index() { var database = new FakeContactDatabase(); var contacts = database.GetAll(); return(View(contacts)); }
// // GET: /Home/ public ActionResult Index() { var database = new FakeContactDatabase(); // ask the database to get all the contacts var contacts = database.GetAll(); // inject the contact data into the view return(View(contacts)); }
public ActionResult Edit() { //load the id from routedata int contactId = int.Parse(RouteData.Values["id"].ToString()); var database = new FakeContactDatabase(); var contact = database.GetById(contactId); return(View(contact)); }
// GET: Home public ActionResult Index() { var database = new FakeContactDatabase(); //get contacts var contacts = database.GetAll(); //inject contact data into the index view return(View(contacts)); }
public ActionResult DeleteContact() { int contactId = int.Parse(Request.Form["ContactId"]); var database = new FakeContactDatabase(); database.Delete(contactId); var contacts = database.GetAll(); return(View("Index", contacts)); }
public ActionResult Edit(int id) { //// Load the id from the RouteData. //// It is stored as object, so we must cast it. //int contactId = int.Parse(RouteData.Values["id"].ToString()); var database = new FakeContactDatabase(); var contact = database.GetById(id); // inject the contact object into the view return(View(contact)); }
public HttpResponseMessage Post(Contact newContact) { var repo = new FakeContactDatabase(); repo.Add(newContact); var response = Request.CreateResponse(HttpStatusCode.Created); string uri = Url.Link("DefaultApi", new { id = newContact.ContactId }); response.Headers.Location = new Uri(uri); return(response); }
public ActionResult EditContact() { var contact = new Contact(); contact.Name = Request.Form["Name"]; contact.PhoneNumber = Request.Form["PhoneNumber"]; contact.ContactId = int.Parse(Request.Form["ContactId"]); var database = new FakeContactDatabase(); database.Edit(contact); return(RedirectToAction("Index")); }
public ActionResult AddContact(Contact c) { //// create a contact //var c = new Contact(); //// get the data from the input fields Name and PhoneNumber //c.Name = Request.Form["Name"]; //c.PhoneNumber = Request.Form["PhoneNumber"]; // create our fake database var database = new FakeContactDatabase(); database.Add(c); // add the contact record to the database return(RedirectToAction("Index")); }
public ActionResult AddContact() { //create a contact var c = new Contact(); // get the data from the text boxes c.Name = Request.Form["Name"]; c.PhoneNumber = Request.Form["PhoneNumber"]; //create Fake Db var database = new FakeContactDatabase(); //add the info to db database.Add(c); //nav to home view return(RedirectToAction("Index")); }
public ActionResult EditContact(Contact c) { //// create a contact //var c = new Contact(); //// get the data from the input fields //// ContactId, Name, and PhoneNuumber //c.Name = Request.Form["Name"]; //c.PhoneNumber = Request.Form["PhoneNumber"]; //c.ContactId = int.Parse(Request.Form["ContactId"]); // create our fake dataase var database = new FakeContactDatabase(); //send the edited contact redord to the database database.Edit(c); // tell the browser to navigate to Home/Index return(RedirectToAction("Index")); }
public Contact Get(int id) { var repo = new FakeContactDatabase(); return(repo.GetById(id)); }
public List <Contact> Get() { var repo = new FakeContactDatabase(); return(repo.GetAll()); }