Exemplo n.º 1
0
        //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));
        }
Exemplo n.º 2
0
        public ActionResult AddContact(Contact contact)
        {
            var database = new FakeContactDatabase();

            database.Add(contact);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        // GET: Home
        public ActionResult Index()
        {
            var database = new FakeContactDatabase();

            var contacts = database.GetAll();

            return(View(contacts));
        }
Exemplo n.º 4
0
        //
        // 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));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        // 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));
        }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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"));
        }
Exemplo n.º 11
0
        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"));
        }
Exemplo n.º 12
0
        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"));
        }
Exemplo n.º 13
0
        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"));
        }
Exemplo n.º 14
0
        public Contact Get(int id)
        {
            var repo = new FakeContactDatabase();

            return(repo.GetById(id));
        }
Exemplo n.º 15
0
        public List <Contact> Get()
        {
            var repo = new FakeContactDatabase();

            return(repo.GetAll());
        }