示例#1
0
        public ActionResult Details(int id)
        {
            var repo   = new Repositories.PersonRepository();
            var person = repo.GetPerson(id);

            return(View(person));
        }
示例#2
0
        public ActionResult Edit(Person person)
        {
            var repo = new Repositories.PersonRepository();

            repo.UpdatePerson(person);

            return(RedirectToAction("Details", new { id = person.PersonID }));
        }
示例#3
0
        public ActionResult Delete(int id)
        {
            var repo = new Repositories.PersonRepository();

            repo.DeletePerson(id);

            return(RedirectToAction("People"));
        }
示例#4
0
        public ActionResult People()
        {
            ViewBag.Message = "Your people page.";

            var repo   = new Repositories.PersonRepository();
            var people = repo.GetPeople();

            return(View(people));
        }
示例#5
0
        public ActionResult Create(Models.Person newPerson)
        {
            if (ModelState.IsValid)
            {
                var repo = new Repositories.PersonRepository();
                repo.CreatePerson(newPerson);

                return(RedirectToAction("Details", new { id = newPerson.PersonID }));
            }
            else
            {
                return(View(newPerson));
            }
        }
示例#6
0
        public IEnumerable <Models.Person> GetContacts(
            string search           = null,
            string personType       = null,
            int?ely                 = null,
            int?subRegion           = null,
            int?county              = null,
            int?greaterArea         = null,
            int?administrativeCourt = null,
            int?municipality        = null)
        {
            Queries.PersonQuery query = new Queries.PersonQuery();

            query.SearchKeyword = search;

            query.ElyIs                 = ely;
            query.SubRegionIs           = subRegion;
            query.CountyIs              = county;
            query.GreaterAreaIs         = greaterArea;
            query.AdministrativeCourtIs = administrativeCourt;
            query.MunicipalityIs        = municipality;

            if (personType == null)
            {
                personType = "any";
            }

            string[] personTypes = (
                from p in personType.Split(',')
                select p.Trim().ToLower()).ToArray();

            query.PersonTypes = personTypes;

            string connStr = ConfigurationManager
                             .ConnectionStrings["urbanPlanningDB"].ToString();

            using (DbConnection db = new SqlConnection(connStr)) {
                db.Open();
                var repository = new Repositories.PersonRepository(db);
                return((List <Models.Person>)repository.FindAll(query));
            }
        }