public static void Inserir(int numero, DateTime date) { using (ObservatorioEntities context = new ObservatorioEntities()) { Processo p = new Processo(); p.Numero = numero; p.DataInicio = date; context.Processos.Add(p); context.SaveChanges(); } }
public static Processo Consultar(int id) { Processo processo = null; using (ObservatorioEntities context = new ObservatorioEntities()) { var processo_ = from Processo p in context.Processos where p.Id == id select p; if (processo_.Count() > 0) { processo = processo_.First(); } } return(processo); }
public static void InserirProcesso(int idDetento, string numero, DateTime dataInicio, string anotacoes, int idJuizo) { if (numero == null || numero.Length == 0) { throw new NegocioException(NegocioExcCode.PROCESSONUMOBRIGATORIO, ""); } using (ObservatorioEntities context = new ObservatorioEntities()) { var detento_ = from Detento d in context.Detentos where d.Id == idDetento select d; if (detento_.Count() == 0) { throw new NegocioException(NegocioExcCode.DETENTOIDNAOENCONTRADO, idDetento.ToString()); } var juizo_ = from Juizo j in context.Juizos where j.Id == idJuizo select j; if (juizo_.Count() == 0) { throw new NegocioException(NegocioExcCode.JUIZONAOENCONTRADO, idJuizo.ToString()); } Processo p = new Processo(); p.Numero = numero; p.DataInicio = dataInicio; p.Detento = detento_.First(); p.Juizo = juizo_.First(); p.Anotacoes = anotacoes; context.Processos.Add(p); context.SaveChanges(); } }
public static void AtualizarProcesso(int idProcesso, string numero, DateTime dataInicio, string anotacoes, int idJuizo) { if (numero == null || numero.Length == 0) { throw new NegocioException(NegocioExcCode.PROCESSONUMOBRIGATORIO, ""); } using (ObservatorioEntities context = new ObservatorioEntities()) { var processo_ = from Processo p in context.Processos where p.Id == idProcesso select p; if (processo_.Count() == 0) { throw new NegocioException(NegocioExcCode.PROCESSONAOENCONTRADO, idProcesso.ToString()); } var juizo_ = from Juizo j in context.Juizos where j.Id == idJuizo select j; if (juizo_.Count() == 0) { throw new NegocioException(NegocioExcCode.JUIZONAOENCONTRADO, idJuizo.ToString()); } Processo p = processo_.First(); p.Numero = numero; p.DataInicio = dataInicio; p.Juizo = juizo_.First(); p.Anotacoes = anotacoes; context.SaveChanges(); } }