public ActionResult Create([Bind(Include = "ObjetivoID,Nome,Dica")] Objetivo objetivo)
        {
            if (ModelState.IsValid)
            {
                db.Objetivos.Add(objetivo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(objetivo));
        }
Пример #2
0
        public ActionResult Create([Bind(Include = "CausaID,RegraID,Nome,Pergunta,Resposta")] Causa causa)
        {
            if (ModelState.IsValid)
            {
                db.Causas.Add(causa);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RegraID = new SelectList(db.Regras, "RegraID", "Nome", causa.RegraID);
            return(View(causa));
        }
        public ActionResult Create([Bind(Include = "ObjetivoID,Nome")] Regra regra)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Regras.Add(regra);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }



            return(View(regra));
        }
Пример #4
0
 public void Adicionar(TEntity entity)
 {
     Context.Set <TEntity>().Add(entity);
     Context.SaveChanges();
 }