Пример #1
0
 public ActionResult Persistir(Comentario c)
 {
     using (SimpleFormContext context = new SimpleFormContext())
     {
         context.Comentarios.Add(c);
         context.SaveChanges();
     }
     return(RedirectToAction("Lista", "Home"));
 }
Пример #2
0
        public ActionResult Lista()
        {
            ICollection <Comentario> lista = new List <Comentario>();

            using (SimpleFormContext context = new SimpleFormContext())
            {
                foreach (Comentario c in context.Comentarios)
                {
                    lista.Add(c);
                }
            }

            return(View(lista));
        }