public string excluirSecaoProblema(SecaoProblema s) { string erro = null; try { db.SecaoProblema.DeleteObject(s); db.SaveChanges(); } catch (Exception ex) { erro = ex.Message; } return erro; }
public ActionResult Edit(int id) { if (Roles.IsUserInRole(User.Identity.Name, "administrador") || (System.Web.Security.Roles.IsUserInRole(User.Identity.Name, "gerencia"))) { SecaoProblema s = new SecaoProblema(); ViewBag.Titulo = "Novo SecaoProblema"; if (id != 0) { s = secaoProblemaModel.obterSecaoProblema(id); ViewBag.Titulo = "Editar SecaoProblema"; } return View(s); } return Redirect("/Shared/Error"); }
public ActionResult Edit(SecaoProblema s) { string erro = null; if (s.IdSecao == 0) erro = secaoProblemaModel.adicionarSecaoProblema(s); else erro = secaoProblemaModel.editarSecaoProblema(s); if (erro == null) { return RedirectToAction("Index"); } else { ViewBag.Erro = erro; return View(s); } }
public string editarSecaoProblema(SecaoProblema s) { string erro = null; try { if (s.EntityState == System.Data.EntityState.Detached) { db.SecaoProblema.Attach(s); } db.ObjectStateManager.ChangeObjectState(s, System.Data.EntityState.Modified); db.SaveChanges(); } catch (Exception ex) { erro = ex.Message; } return erro; }
/// <summary> /// Deprecated Method for adding a new object to the SecaoProblema EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSecaoProblema(SecaoProblema secaoProblema) { base.AddObject("SecaoProblema", secaoProblema); }
/// <summary> /// Create a new SecaoProblema object. /// </summary> /// <param name="idSecao">Initial value of the IdSecao property.</param> /// <param name="descricao">Initial value of the Descricao property.</param> public static SecaoProblema CreateSecaoProblema(global::System.Int32 idSecao, global::System.String descricao) { SecaoProblema secaoProblema = new SecaoProblema(); secaoProblema.IdSecao = idSecao; secaoProblema.Descricao = descricao; return secaoProblema; }