public ActionResult Create(Sexo s) { if (ModelState.IsValid) { try { using(var mc = new ModelContainer()) { mc.AddToSexos(s); mc.SaveChanges(); } return RedirectToAction("Index"); } catch(Exception ex) { ModelState.AddModelError("MSG", ex); return View(); } } else { return View(); } }
/// <summary> /// Create a new Sexo object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="nome">Initial value of the Nome property.</param> public static Sexo CreateSexo(global::System.String id, global::System.String nome) { Sexo sexo = new Sexo(); sexo.Id = id; sexo.Nome = nome; return sexo; }
/// <summary> /// Deprecated Method for adding a new object to the Sexos EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSexos(Sexo sexo) { base.AddObject("Sexos", sexo); }