コード例 #1
0
 public void Save(sentenca entity)
 {
     DataModel.Entry(entity).State = entity.id_sentenca == 0 ?
        EntityState.Added :
        EntityState.Modified;
     DataModel.SaveChanges();
 }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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();
            }
        }
コード例 #5
0
        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();
            }
        }
コード例 #6
0
 public void Delete(sentenca entity)
 {
     DataModel.sentenca.Remove(entity);
     DataModel.SaveChanges();
 }
コード例 #7
0
 public void Edit(sentenca entity)
 {
     Save(entity);
 }
コード例 #8
0
 public void Create(sentenca entity)
 {
     Save(entity);
 }