コード例 #1
0
 public virtual ActionResult DeleteConfirmed(int id)
 {
     repo.ExcluirPorId(id);
     TempData["Alerta"] = new Alerta()
     {
         Mensagem = "Registro excluído com sucesso", Tipo = "success"
     };
     return(RedirectToAction("Index"));
 }
コード例 #2
0
        public virtual void Create(string postedData)
        {
            var js        = new JavaScriptSerializer();
            V   viewModel = js.Deserialize <V>(postedData);
            var _model    = new T();

            _model = viewModel.ToModel();
            repo.Incluir(_model);

            TempData["Alerta"] = new Alerta()
            {
                Mensagem = "Registro gravado com sucesso", Tipo = "success"
            };
        }
コード例 #3
0
 public virtual ActionResult Edit(T model)
 {
     if (ModelState.IsValid)
     {
         repo.Alterar(model);
         TempData["Alerta"] = new Alerta()
         {
             Mensagem = "Registro alterado com sucesso", Tipo = "success"
         };
         return(RedirectToAction("Index"));
     }
     PreAlteracao(model);
     return(FolderViewName() == String.Empty ? View(model) : View("~/Views/" + FolderViewName() + "/Edit.cshtml", model));
 }
コード例 #4
0
        public virtual ActionResult Create(T model)
        {
            if (ModelState.IsValid)
            {
                repo.Incluir(model);
                TempData["Alerta"] = new Alerta()
                {
                    Mensagem = "Registro gravado com sucesso", Tipo = "success"
                };

                if (Request.Form["novo"] != null && Request.Form["novo"].Equals("1"))
                {
                    return(RedirectToAction("Create"));
                }

                return(RedirectToAction("Index"));
            }
            PreInclusao();
            return(FolderViewName() == String.Empty ? View(model) : View("~/Views/" + FolderViewName() + "/Create.cshtml", model));
        }