コード例 #1
0
 // Função GET de Trick
 public ActionResult Index()
 {
     using (TricksModel model = new TricksModel())
     {
         List <Trick> lista = model.Read();
         return(View(lista));
     }
 }
コード例 #2
0
        public ActionResult Create(IFormCollection form)
        {
            Trick trick = new Trick
            {
                Name   = form["Name"],
                Family = form["Family"],
            };

            int parsedInt = 0;

            if (int.TryParse(form["Value"], out parsedInt))
            {
                trick.Value = parsedInt;
            }
            else
            {
            }

            using (TricksModel model = new TricksModel())
            {
                model.Create(trick);
                return(RedirectToAction("Index"));
            }
        }