示例#1
0
        public IActionResult Add(Person person)
        {
            var db = new PeopleDb(_connectionString);

            db.Add(person);
            return(Json(person));
        }
示例#2
0
        public ActionResult Delete(int pid)
        {
            var db = new PeopleDb(ConfigurationManager.ConnectionStrings["MvcApplication2.Properties.Settings.PeopleConStr"].ConnectionString);

            db.Delete(pid);
            return(RedirectToAction("Index"));
        }
示例#3
0
        public IActionResult GetAll()
        {
            var           db  = new PeopleDb(_connectionString);
            List <Person> ppl = db.GetAll();

            return(Json(ppl));
        }
示例#4
0
        public ActionResult Edit(int pid)
        {
            var    db     = new PeopleDb(ConfigurationManager.ConnectionStrings["MvcApplication2.Properties.Settings.PeopleConStr"].ConnectionString);
            Person person = db.GetById(pid);

            return(View(person));
        }
示例#5
0
        public ActionResult DeletePerson(int personId)
        {
            PeopleDb pdb = new PeopleDb(Properties.Settings.Default.conStr);

            pdb.DeletePerson(personId);
            return(Json(personId));
        }
示例#6
0
        public ActionResult Index()
        {
            var db = new PeopleDb(ConfigurationManager.ConnectionStrings["MvcApplication2.Properties.Settings.PeopleConStr"].ConnectionString);
            IEnumerable <Person> ppl = db.GetAll();

            return(View(ppl));
        }
示例#7
0
        public ActionResult Index()
        {
            PeopleDb             pdb    = new PeopleDb(Properties.Settings.Default.conStr);
            IEnumerable <Person> people = pdb.GetAllPeople();

            return(View(people));
        }
示例#8
0
        public ActionResult Index()
        {
            var db  = new PeopleDb(@"Data Source=.\sqlexpress;Initial Catalog=Food;Integrated Security=True");
            var ppl = db.GetAll();

            return(View(ppl));
        }
示例#9
0
        public IActionResult Delete(int id)
        {
            PeopleDb db = new PeopleDb(_connectionString);

            db.Delete(id);
            return(Redirect("/postdemo/showpeople"));
        }
示例#10
0
        public ActionResult Edit(int personId)
        {
            var      db = new PeopleDb(@"Data Source=.\sqlexpress;Initial Catalog=Food;Integrated Security=True");
            Customer c  = db.FindById(personId);

            return(View(c));
        }
示例#11
0
        public IActionResult Update(Person person)
        {
            PeopleDb db = new PeopleDb(_connectionString);

            db.Update(person);
            return(Redirect("/postdemo/showpeople"));
        }
示例#12
0
        public ActionResult Delete(int id)
        {
            var db = new PeopleDb(@"Data Source=.\sqlexpress;Initial Catalog=Food;Integrated Security=True");

            db.Delete(id);
            return(RedirectToAction("Index"));
        }
 public virtual void SaveItem(T obj)
 {
     using (PeopleDb db = new PeopleDb()) {
         db.Set <T>().Add(obj);
         db.SaveChanges();
     }
 }
示例#14
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"));
        }
示例#15
0
        public IActionResult EditPerson(Person person)
        {
            var db = new PeopleDb(_conStr);

            db.EditPerson(person);
            return(Json(person));
        }
示例#16
0
        public ActionResult EditPerson(Person person)
        {
            PeopleDb pdb = new PeopleDb(Properties.Settings.Default.conStr);

            pdb.EditPerson(person);
            return(Json(person));
        }
示例#17
0
        public IActionResult DeletePerson(int id)
        {
            var db = new PeopleDb(_conStr);

            db.DeletePerson(id);
            return(Json(id));
        }
示例#18
0
        public ActionResult GetPeople()
        {
            PeopleDb             pdb    = new PeopleDb(Properties.Settings.Default.conStr);
            IEnumerable <Person> people = pdb.GetAllPeople();

            return(Json(people, JsonRequestBehavior.AllowGet));
        }
示例#19
0
 public void SaveItem(Person obj)
 {
     using (var PeopleDb = new PeopleDb()) {
         PeopleDb.Person.Add(obj);
         PeopleDb.SaveChanges();
     }
 }
示例#20
0
        public ActionResult Delete(int id)
        {
            PeopleDb db = new PeopleDb(_connectionString);

            db.Delete(id);
            return(Redirect("/people/index"));
        }
示例#21
0
        public ActionResult Add(Person person)
        {
            PeopleDb db = new PeopleDb(_connectionString);

            db.Add(person);
            return(Redirect("/people/index"));
        }
示例#22
0
        public ActionResult Save(string name, string address, string nopoint)
        {
            var      db = new PeopleDb(@"Data Source=.\sqlexpress;Initial Catalog=Food;Integrated Security=True");
            Customer c  = new Customer();

            c.Name    = name;
            c.Address = address;
            db.Add(c);
            return(RedirectToAction("Index"));
        }
示例#23
0
        public ActionResult Index()
        {
            PeopleDb        db = new PeopleDb(_connectionString);
            PeopleViewModel vm = new PeopleViewModel
            {
                People = db.GetAll()
            };

            return(View(vm));
        }
示例#24
0
        public IActionResult AddPerson(List <Person> ppl)
        {
            PeopleDb db = new PeopleDb(_conStr);

            foreach (Person p in ppl)
            {
                db.AddPerson(p);
            }
            return(Redirect("/"));
        }
        public virtual IEnumerable <T> GetItems()
        {
            IEnumerable <T> results = null;

            using (PeopleDb db = new PeopleDb()) {
                results = db.Set <T>().ToList();
            }

            return(results);
        }
示例#26
0
        public ActionResult Edit(string name, string address, int customerId)
        {
            var      db = new PeopleDb(@"Data Source=.\sqlexpress;Initial Catalog=Food;Integrated Security=True");
            Customer c  = new Customer();

            c.Name    = name;
            c.Address = address;
            c.Id      = customerId;
            db.Update(c);
            return(RedirectToAction("Index"));
        }
        public MainPageViewModel()
        {
            peopleDb = new PeopleDb(Constants.DatabasePath);
            var people = peopleDb.GetPeople();

            if (people.Any())
            {
                var lastRecord = people.OrderByDescending(by => by.PersonId).First();
                firstName = lastRecord.FirstName;
                lastName  = lastRecord.LastName;
            }
        }
示例#28
0
        public IActionResult Index()
        {
            PeopleDb        db = new PeopleDb(_connectionString);
            PeopleViewModel vm = new PeopleViewModel();

            vm.People = db.GetPeople();
            if (TempData["message"] != null)
            {
                vm.Message = (string)TempData["message"];
            }
            return(View(vm));
        }
示例#29
0
        public IActionResult Edit(int id)
        {
            PeopleDb db     = new PeopleDb(_connectionString);
            Person   person = db.GetPerson(id);

            if (person == null)
            {
                return(Redirect("/postdemo/showpeople"));
            }

            return(View(person));
        }
示例#30
0
 public ActionResult Edit(int personId, string firstName, string lastName, int? age)
 {
     var db = new PeopleDb(ConfigurationManager.ConnectionStrings["MvcApplication2.Properties.Settings.PeopleConStr"].ConnectionString);
     Person p = new Person
     {
         FirstName = firstName,
         LastName = lastName,
         Age = age,
         Id = personId
     };
     db.Update(p);
     return RedirectToAction("Index");
 }
示例#31
0
        public IActionResult AddPerson(string firstName, string lastName, int age)
        {
            Person person = new Person
            {
                FirstName = firstName,
                LastName  = lastName,
                Age       = age
            };
            PeopleDb db = new PeopleDb(_connectionString);

            db.Add(person);
            return(Redirect("/postdemo/showpeople"));
        }
示例#32
0
 public ActionResult Delete(int pid)
 {
     var db = new PeopleDb(ConfigurationManager.ConnectionStrings["MvcApplication2.Properties.Settings.PeopleConStr"].ConnectionString);
     db.Delete(pid);
     return RedirectToAction("Index");
 }
示例#33
0
 public ActionResult Index()
 {
     var db = new PeopleDb(ConfigurationManager.ConnectionStrings["MvcApplication2.Properties.Settings.PeopleConStr"].ConnectionString);
     IEnumerable<Person> ppl = db.GetAll();
     return View(ppl);
 }
示例#34
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");
 }
示例#35
0
 public ActionResult Edit(int pid)
 {
     var db = new PeopleDb(ConfigurationManager.ConnectionStrings["MvcApplication2.Properties.Settings.PeopleConStr"].ConnectionString);
     Person person = db.GetById(pid);
     return View(person);
 }