Esempio n. 1
0
        public ActionResult AddPerson(Person person)
        {
            PeopleDb pdb = new PeopleDb(Properties.Settings.Default.conStr);

            pdb.AddPerson(person);
            return(Json(person));
        }
Esempio n. 2
0
        public IActionResult AddPerson(Person person)
        {
            var db = new PeopleDb(_conStr);

            db.AddPerson(person);
            return(Json(person));
        }
Esempio n. 3
0
        public ActionResult Add(string firstName, string lastName, int?age)
        {
            var db = new PeopleDb(ConfigurationManager.ConnectionStrings["MvcApplication2.Properties.Settings.PeopleConStr"].ConnectionString);

            db.AddPerson(firstName, lastName, age);
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
        public IActionResult AddPerson(List <Person> ppl)
        {
            PeopleDb db = new PeopleDb(_conStr);

            foreach (Person p in ppl)
            {
                db.AddPerson(p);
            }
            return(Redirect("/"));
        }
Esempio n. 5
0
        public IActionResult Add(List <Person> people)
        {
            PeopleDb db = new PeopleDb(_connectionString);

            foreach (var person in people)
            {
                db.AddPerson(person);
            }

            string text = "people";

            if (people.Count == 1)
            {
                text = "person";
            }
            TempData["message"] = $"{people.Count} {text} added successfully!";

            return(Redirect("/Home/Index"));
        }
Esempio n. 6
0
 public ActionResult Add(string firstName, string lastName, int? age)
 {
     var db = new PeopleDb(ConfigurationManager.ConnectionStrings["MvcApplication2.Properties.Settings.PeopleConStr"].ConnectionString);
     db.AddPerson(firstName, lastName, age);
     return RedirectToAction("Index");
 }