public void Save(sentenca entity) { DataModel.Entry(entity).State = entity.id_sentenca == 0 ? EntityState.Added : EntityState.Modified; DataModel.SaveChanges(); }
public ActionResult Create(sentenca sentenca) { LoadFormProcesso(); try { if (validate(sentenca)) return View(sentenca); SentencaRepository.Create(sentenca); int idProcesso = sentenca.fk_id_processo; processo processo = ProcessoRepository.GetOne(idProcesso); processo.juri.juri_ativo = false; ProcessoRepository.Edit(processo); return RedirectToAction("ListByIdProcess", new { id = sentenca.fk_id_processo, message = "Dados cadastrados com sucesso!" }); } catch { return View(sentenca); } }
public bool validate(sentenca entity) { bool retorno = false; if (string.IsNullOrEmpty(entity.texto_sentenca)) { ModelState.AddModelError("texto_sentenca", "Campo obrigatório"); retorno = true; } return retorno; }
public ActionResult Delete(int id, sentenca sentenca) { try { sentenca = SentencaRepository.GetOne(id); SentencaRepository.Delete(sentenca); return RedirectToAction("ListByIdProcess", new { id = sentenca.fk_id_processo, message = "Dados excluídos com sucesso!" }); } catch { return View(); } }
public ActionResult Edit(int id, sentenca sentenca) { LoadFormProcesso(); try { if (validate(sentenca)) return View(sentenca); SentencaRepository.Edit(sentenca); return RedirectToAction("ListByIdProcess", new { id = sentenca.fk_id_processo, message = "Dados editados com sucesso!" }); } catch { return View(); } }
public void Delete(sentenca entity) { DataModel.sentenca.Remove(entity); DataModel.SaveChanges(); }
public void Edit(sentenca entity) { Save(entity); }
public void Create(sentenca entity) { Save(entity); }