private void PersonFindByIdForm_Load(object sender, EventArgs e)
        {
            var person = dao.FindById(personId);

            tbId.Text   = person.Id.ToString();
            tbName.Text = person.Name;
            tbAge.Text  = person.Age.ToString();
            tbWage.Text = person.Wage.ToString();
        }
        public void TestUpdate()
        {
            Insert();
            dao.Update(1, new Person(1, "newfoo", 66, 666.6));
            var p = dao.FindById(1);

            Assert.AreEqual(1, p.Id);
            Assert.AreEqual(66, p.Age);
            Assert.AreEqual(666.6, p.Wage);
            Assert.AreEqual("newfoo", p.Name);
            Clean();
        }
Esempio n. 3
0
        public ActionResult <Person> GetByID(long id)
        {
            PersonDAO personDAO = new PersonDAO(_connection);
            var       person    = personDAO.FindById(id);

            if (person == null)
            {
                return(NotFound()); //404 not found
            }

            return(person);
        }
Esempio n. 4
0
        private static void FindById()
        {
            Console.WriteLine("insert id of Person to be found: ");
            string input = Console.ReadLine();

            try {
                long   id = Convert.ToInt64(input);
                Person p  = dao.FindById(id);
                Console.WriteLine(p);
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 5
0
        public IActionResult Delete(long id)
        {
            PersonDAO personDAO = new PersonDAO(_connection);
            var       toDel     = personDAO.FindById(id);

            if (toDel == null)
            {
                NotFound();
            }

            personDAO.Delete(toDel);

            return(NoContent());
        }
Esempio n. 6
0
        public void TestDelete()
        {
            Insert();
            var list = dao.FindAll();

            Assert.AreEqual(2, list.Count);
            var p = dao.FindById(1);

            Assert.AreEqual("foo", p.Name);
            dao.Delete(1);
            list = dao.FindAll();
            Assert.AreEqual(1, list.Count);
            dao.Delete(2);
            list = dao.FindAll();
            Assert.AreEqual(0, list.Count);
            Clean();
        }
Esempio n. 7
0
        public IActionResult Update(long id, Person person)
        {
            PersonDAO personDAO = new PersonDAO(_connection);
            var       pOld      = personDAO.FindById(id);

            if (pOld == null)
            {
                return(NotFound());
            }

            pOld.FirstName = person.FirstName;
            pOld.LastName  = person.LastName;
            pOld.Age       = person.Age;
            pOld.Email     = person.Email;

            personDAO.Update(pOld);

            return(NoContent());
        }
 public ActionResult Visualizar(int id)
 {
     return(View(personDAO.FindById(id)));
 }