public TimeModelConsulta Editar(int id) { try { TimeDal d = new TimeDal(); Time t = d.FindById(id); if (t != null) { var model = new TimeModelConsulta(); model.IdTime = t.IdTime; model.Nome = t.Nome; model.DataFundacao = t.DataFundacao.ToString("dd/MM/yyyy"); return(model); } else { throw new Exception("Time não encontrado."); } } catch (Exception e) { throw new Exception("Erro: " + e.Message); } }
public JsonResult Editar(TimeModelEdicao model) { try { TimeDal d = new TimeDal(); Time t = d.FindById(model.IdTime); if (t != null) { model.Nome = t.Nome; model.DataFundacao = t.DataFundacao; } return Json(model); } catch (Exception e) { return Json(e.Message); } }
public string Excluir(int id) { try { TimeDal d = new TimeDal(); Time t = d.FindById(id); if (t != null) { d.Delete(t); return("Time excluído."); } else { return("Time não encontrado."); } } catch (Exception e) { return(e.Message); } }
public ActionResult Editar(int id) { var model = new TimeModelEdicao(); try { TimeDal d = new TimeDal(); Time t = d.FindById(id); if (t != null) { model.IdTime = t.IdTime; model.Nome = t.Nome; model.DataFundacao = t.DataFundacao; } } catch (Exception e) { ViewBag.Mensagem = e.Message; } return View(model); }
public JsonResult Excluir(TimeModelEdicao model) { try { TimeDal d = new TimeDal(); Time t = d.FindById(model.IdTime); if (t != null) { d.Delete(t); return Json("Time excluído, atualizando..."); } else { return Json("Time não encontrado."); } } catch (Exception e) { return Json(e.Message); } }
public ActionResult Excluir(int id) { try { TimeDal d = new TimeDal(); d.Delete(d.FindById(id)); ViewBag.Mensagem = "Time excluído com sucesso."; } catch (Exception e) { ViewBag.Mensagem = e.Message; } return RedirectToAction("Consulta"); }