public IActionResult Cadastrar(PlanoMOD planoMOD) { if (ModelState.IsValid) { try { PlanoBUS.CadastrarPlano(planoMOD); #region mensagem ViewBag.Mensagem = "Plano cadastrado com sucesso!"; ViewBag.Style = "display:block; text-align:center; margin-top: 5%"; ViewBag.Class = "alert alert-success"; #endregion return(View(planoMOD)); } catch (Exception) { #region mensagem ViewBag.Mensagem = "Erro ao cadastrar plano!"; ViewBag.Style = "display:block; text-align:center; margin-top: 5%"; ViewBag.Class = "alert alert-danger"; #endregion return(View(planoMOD)); } } else { #region mensagem ViewBag.Mensagem = "Preenchimento invalido!"; ViewBag.Style = "display:block; text-align:center; margin-top: 5%"; ViewBag.Class = "alert alert-danger"; #endregion return(View(planoMOD)); } }
public static void Alterar(PlanoMOD planoMOD) { try { PlanoRPO.Alterar(planoMOD); } catch (Exception) { throw; } }
public static PlanoMOD CadastrarPlano(PlanoMOD planoMOD) { try { PlanoRPO.Cadastrar(planoMOD); return(planoMOD); } catch (Exception) { throw; } }
public static void Cadastrar(PlanoMOD planoMOD) { try { using (SGCPSContext context = new SGCPSContext()) { context.Planos.Add(planoMOD); context.SaveChanges(); } } catch (Exception e) { throw; } }
public static void Alterar(PlanoMOD planoMOD) { try { using (SGCPSContext context = new SGCPSContext()) { context.Planos.Update(planoMOD); context.SaveChanges(); } } catch (Exception) { throw; } }
public static void Alterar(PlanoMOD planoMOD) { try { using (SGCPSContext context = new SGCPSContext()) { PlanoMOD ObjPlanoMOD = context.Planos.Where(x => x.Id == planoMOD.Id).First(); ObjPlanoMOD.Plano = planoMOD.Plano; ObjPlanoMOD.TelefoneDoPlano = planoMOD.TelefoneDoPlano; context.Planos.Update(ObjPlanoMOD); context.SaveChanges(); } } catch (Exception) { throw; } }