public IActionResult ExcluirEscola(int id) { EscolaModel objEscola = new EscolaModel(); objEscola.Excluir(id); return(RedirectToAction("Index")); }
public IActionResult Visualizar(int id) { EscolaModel objEscola = new EscolaModel(); ViewBag.Registro = objEscola.CarregarRegistro(id); return(View()); }
/*IHttpContextAccessor HttpContextAccessor; * public EscolaController(IHttpContextAccessor httpContextAccessor) * { * HttpContextAccessor = httpContextAccessor; * }*/ public IActionResult Index() { EscolaModel objEscola = new EscolaModel(); ViewBag.ListaEscola = objEscola.ListaEscola(); return(View()); }
public IActionResult CriarEscola(int?id) { if (id != null) { EscolaModel objEscola = new EscolaModel(); ViewBag.Registro = objEscola.CarregarRegistro(id); } return(View()); }
public IActionResult CriarEscola(EscolaModel formulario) { if (ModelState.IsValid) { //formulario.HttpContextAccessor = httpContextAccessor; formulario.CadastrarEscola(); return(RedirectToAction("Index")); } return(View()); }
public bool Update(EscolaModel entity) { try { this.UOW.Escolas.Update(entity); this.UOW.Commit(); return(true); } catch (Exception ex) { throw new Exception(ex.Message); } }
public EscolaModel Add(EscolaModel entity) { try { var escola = this.UOW.Escolas.Insert(entity); this.UOW.Commit(); return(escola); } catch (Exception ex) { throw new Exception(ex.Message); } }
public bool Delete(EscolaModel entity) { try { if (entity.ID > 0) { this.UOW.Escolas.Delete(entity.ID); this.UOW.Commit(); return(true); } return(false); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult Save(EscolaModel model) { ActionResult result = null; EscolaModel escola = new EscolaModel(); try { if (model.ID > 0) { result = RedirectToAction(ActionAlterar, new { id = model.ID }); escola = this.escolaBusiness.GetById(model.ID); escola.Nome = model.Nome; escola.LastModifiedDate = DateTime.Now; escola.Status = "UPDATED"; escola.UserID = 1; this.escolaBusiness.Update(escola); } else { result = RedirectToAction(ActionNovo); escola.Nome = model.Nome; escola.LastModifiedDate = DateTime.Now; escola.Status = "ADDED"; escola.UserID = 1; this.escolaBusiness.Add(escola); } TempData[Constants.KEY_SUCCESS_MESSAGE] = Constants.GENERIC_MSG_FORM_SUCCESS_SAVE; result = RedirectToAction(ActionLista); } catch (Exception ex) { TempData[Constants.KEY_ERROR_MESSAGE] = ex.ToStringAll(); } return(result); }