Example #1
0
        public ActionResult Edit(Solucao s)
        {
            string erro = solucaoModel.validarSolucao(s);
            if (erro == null)
            {
                if (s.IdSolucao == 0)
                {
                    erro = solucaoModel.adicionarSolucao(s);
                }
                else
                {
                    erro = solucaoModel.editarSolucao(s);
                }
            }

            if (erro == null)
            {
                return RedirectToAction("Index");
            }
            else
            {
                ViewBag.Erro = erro;
                return View(s);
            }
        }
Example #2
0
 public string excluirSolucao(Solucao s)
 {
     string erro = null;
     try
     {
         db.DeleteObject(s);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         erro = ex.Message;
     }
     return erro;
 }
Example #3
0
 public string adicionarSolucao(Solucao s)
 {
     string erro = null;
     try
     {
         db.Solucao.AddObject(s);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         erro = ex.Message;
     }
     return erro;
 }
Example #4
0
 public string editarSolucao(Solucao s)
 {
     string erro = null;
     try
     {
         if (s.EntityState == System.Data.EntityState.Detached)
         {
             db.Solucao.Attach(s);
         }
         db.ObjectStateManager.ChangeObjectState(s, System.Data.EntityState.Modified);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         erro = ex.Message;
     }
     return erro;
 }
Example #5
0
        public ActionResult Edit(int id)
        {
            if (Roles.IsUserInRole(User.Identity.Name, "administrador") || (System.Web.Security.Roles.IsUserInRole(User.Identity.Name, "gerencia")))
            {
                Solucao s = new Solucao();
                int idProblema = 1;

                if (id != 0)
                {
                    s = solucaoModel.obterSolucao(id);
                    idProblema = s.IdProblema;

                }

                ViewBag.IdProblema = new SelectList(problemaModel.todosProblemas(), "IdProblema", "Descricao", idProblema);

                return View(s);
            }
            return Redirect("/Shared/Error");
        }
Example #6
0
 public ActionResult EditSolucao(Solucao s)
 {
     string erro = null;
     if (s.IdSolucao == 0)
     {
         erro = solucaoModel.adicionarSolucao(s);
     }
     else
     {
         erro = solucaoModel.editarSolucao(s);
     }
     if (erro == null)
     {
         return RedirectToAction("ListaSolucoes", new { idProblema = s.IdProblema });
     }
     else
     {
         ViewBag.Erro = erro;
         return View(s);
     }
 }
Example #7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Solucao EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSolucao(Solucao solucao)
 {
     base.AddObject("Solucao", solucao);
 }
Example #8
0
 /// <summary>
 /// Create a new Solucao object.
 /// </summary>
 /// <param name="idSolucao">Initial value of the IdSolucao property.</param>
 /// <param name="descricao">Initial value of the Descricao property.</param>
 /// <param name="idProblema">Initial value of the IdProblema property.</param>
 public static Solucao CreateSolucao(global::System.Int32 idSolucao, global::System.String descricao, global::System.Int32 idProblema)
 {
     Solucao solucao = new Solucao();
     solucao.IdSolucao = idSolucao;
     solucao.Descricao = descricao;
     solucao.IdProblema = idProblema;
     return solucao;
 }
Example #9
0
        public ActionResult EditSolucao(int idProblema, int idSolucao)
        {
            if (Roles.IsUserInRole(User.Identity.Name, "administrador") || (System.Web.Security.Roles.IsUserInRole(User.Identity.Name, "gerencia")))
            {
            Solucao s = new Solucao();
            s.IdProblema = idProblema;

            if (idSolucao != 0)
            {
                s = solucaoModel.obterSolucao(idSolucao);
            }

            return View(s);
            }
            return Redirect("/Shared/Error");
        }
Example #10
0
        public string validarSolucao(Solucao s)
        {
            string erro = null;

            if (s.Descricao == null || s.Descricao == "")
            {
                return "Descricao obrigatória!";
            }

            return erro;
        }