Exemple #1
0
 public ActionResult Edit(int id)
 {
     Marca m = new Marca();
     ViewBag.Titulo = "Nova Marca";
     if (id != 0)
     {
         m = marcaModel.obterMarca(id);
         ViewBag.Titulo = "Editar Marca";
     }
     return View(m);
 }
Exemple #2
0
 public string excluirMarca(Marca m)
 {
     string erro = null;
     try
     {
         db.DeleteObject(m);
         db.SaveChanges();
     } catch (Exception ex)
     {
         erro = ex.Message;
     }
     return erro;
 }
Exemple #3
0
 public string adicionarMarca(Marca m)
 {
     string erro = null;
     try
     {
         db.Marca.AddObject(m);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         erro = ex.Message;
     }
     return erro;
 }
Exemple #4
0
 public ActionResult Edit(Marca m)
 {
     string erro = null;
     if (m.IdMarca == 0)
         erro = marcaModel.adicionarMarca(m);
     else
         erro = marcaModel.editarMarca(m);
     if (erro == null)
     {
         return RedirectToAction("Index");
     }
     else
     {
         ViewBag.Erro = erro;
         return View(m);
     }
 }
Exemple #5
0
 public string editarMarca(Marca m)
 {
     string erro = null;
     try
     {
         if (m.EntityState == System.Data.EntityState.Detached)
         {
             db.Marca.Attach(m);
         }
         db.ObjectStateManager.ChangeObjectState(m,
             System.Data.EntityState.Modified);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         erro = ex.Message;
     }
     return erro;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Marca EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMarca(Marca marca)
 {
     base.AddObject("Marca", marca);
 }
 /// <summary>
 /// Create a new Marca object.
 /// </summary>
 /// <param name="idMarca">Initial value of the IdMarca property.</param>
 /// <param name="descricao">Initial value of the Descricao property.</param>
 public static Marca CreateMarca(global::System.Int32 idMarca, global::System.String descricao)
 {
     Marca marca = new Marca();
     marca.IdMarca = idMarca;
     marca.Descricao = descricao;
     return marca;
 }