Exemplo n.º 1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            // Use LocalDB for Entity Framework by default
            Database.DefaultConnectionFactory = new SqlConnectionFactory(@"Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True");

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            using (var context = new EntitySplittingEntities())
            {
                var person = new Person
                {
                    FirstName = "Irina",
                    LastName = "Doe",
                    Email = "*****@*****.**",
                    Phone = "555-555-5555"
                };

                context.People.Add(person);
                context.SaveChanges();

                foreach (var item in context.People)
                {
                    Console.WriteLine(item.FirstName);
                }
            }
        }
Exemplo n.º 2
0
 public ActionResult Edit(Person person)
 {
     if (ModelState.IsValid)
     {
         db.Entry(person).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(person);
 }
Exemplo n.º 3
0
        public ActionResult Create(Person person)
        {
            if (ModelState.IsValid)
            {
                db.People.Add(person);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(person);
        }