Пример #1
0
        // GET: Person/Edit/5
        public ActionResult Edit(int id)
        {
            induccionEntities entity = new induccionEntities();
            person            person = new person();

            using (entity)
            {
                person = entity.people.Where(entityPerson => entityPerson.id == id).FirstOrDefault();
            }

            return(View(person));
        }
Пример #2
0
        // GET: Person
        public ActionResult Index()
        {
            induccionEntities entity = new induccionEntities();
            List <person>     person = new List <person>();

            using (entity)
            {
                person = entity.people.ToList();
            }

            return(View(person));
        }
Пример #3
0
        public ActionResult About()
        {
            induccionEntities entity = new induccionEntities();
            List <person>     person = new List <person>();

            using (entity)
            {
                person = entity.people.ToList();
            }

            ViewBag.Message = "Your application description page.";

            return(View(person));
        }
Пример #4
0
        public person GetPerson()
        {
            induccionEntities entity = new induccionEntities();
            person            person = new person();
            gender            gender = new gender();

            using (entity)
            {
                person        = entity.people.SqlQuery("SELECT P.id, P.name, surname, age, identification, sex FROM person P ").FirstOrDefault();
                person.gender = entity.genders.Where(X => X.id == person.id).FirstOrDefault();
            }

            return(person);
        }
Пример #5
0
        public ActionResult Edit(int id, person collection)
        {
            try
            {
                using (induccionEntities entity = new induccionEntities())
                {
                    entity.Entry(collection).State = System.Data.Entity.EntityState.Modified;
                    entity.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Пример #6
0
        public ActionResult Create(person collection)
        {
            try
            {
                using (induccionEntities entity = new induccionEntities())
                {
                    entity.people.Add(collection);
                    entity.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #7
0
        public ActionResult Delete(int id, person collection)
        {
            try
            {
                person users = new person();
                using (induccionEntities entity = new induccionEntities())
                {
                    users = entity.people.Where(entityPerson => entityPerson.id == id).FirstOrDefault();
                    entity.people.Remove(users);
                    entity.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }