Esempio n. 1
0
        public ActionResult Create(Pessoa p)
        {
            try
            {
                var mc = new ModelContainer();

                mc.AddToPessoas(p);
                mc.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Esempio n. 2
0
        public ActionResult Delete(Pessoa p)
        {
            try
            {
                var mc = new ModelContainer();

                mc.Pessoas.Attach(p);
                mc.Pessoas.DeleteObject(p);
                mc.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Esempio n. 3
0
        public ActionResult Edit(int id, Pessoa p)
        {
            try
            {
                var mc = new ModelContainer();

                mc.Pessoas.Attach(p);
                mc.ObjectStateManager.ChangeObjectState(p, EntityState.Modified);
                mc.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Pessoas EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPessoas(Pessoa pessoa)
 {
     base.AddObject("Pessoas", pessoa);
 }
Esempio n. 5
0
 /// <summary>
 /// Create a new Pessoa object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="nome">Initial value of the Nome property.</param>
 public static Pessoa CreatePessoa(global::System.Int32 id, global::System.String nome)
 {
     Pessoa pessoa = new Pessoa();
     pessoa.Id = id;
     pessoa.Nome = nome;
     return pessoa;
 }