private void NotificarCriadorEventoDataPassadaAprovado(Evento evento, long codigoDaNotificacao) { var escola = repositorioUe.ObterPorCodigo(evento.UeId); if (escola == null) { throw new NegocioException("Não foi possível localizar a Ue deste evento."); } var linkParaEvento = $"{configuration["UrlFrontEnd"]}calendario-escolar/eventos/editar/:{evento.Id}/"; var usuario = servicoUsuario.ObterUsuarioPorCodigoRfLoginOuAdiciona(evento.CriadoRF); repositorioNotificacao.Salvar(new Notificacao() { UeId = evento.UeId, UsuarioId = usuario.Id, Ano = evento.CriadoEm.Year, Categoria = NotificacaoCategoria.Aviso, DreId = evento.DreId, Titulo = "Criação de evento com data passada", Tipo = NotificacaoTipo.Calendario, Codigo = codigoDaNotificacao, Mensagem = $"O evento {evento.Nome} - {evento.DataInicio.Day}/{evento.DataInicio.Month}/{evento.DataInicio.Year} do calendário {evento.TipoCalendario.Nome} da {escola.Nome} foi aceito. Agora este evento está visível para todos os usuários. Para visualizá-lo clique <a href='{linkParaEvento}'>aqui</a>." }); }
public async Task <bool> Executar(FiltroRelatorioBoletimDto filtroRelatorioBoletimDto) { if (repositorioDre.ObterPorCodigo(filtroRelatorioBoletimDto.DreCodigo) == null) { throw new NegocioException("Não foi possível encontrar a DRE"); } if (repositorioUe.ObterPorCodigo(filtroRelatorioBoletimDto.UeCodigo) == null) { throw new NegocioException("Não foi possível encontrar a UE"); } if (!string.IsNullOrEmpty(filtroRelatorioBoletimDto.TurmaCodigo)) { int codigoTurma; if (int.TryParse(filtroRelatorioBoletimDto.TurmaCodigo, out codigoTurma) && codigoTurma <= 0) { filtroRelatorioBoletimDto.TurmaCodigo = String.Empty; } else if (await repositorioTurma.ObterPorCodigo(filtroRelatorioBoletimDto.TurmaCodigo) == null) { throw new NegocioException("Não foi possível encontrar a turma"); } } unitOfWork.IniciarTransacao(); var usuarioLogado = await mediator.Send(new ObterUsuarioLogadoQuery()); filtroRelatorioBoletimDto.Usuario = usuarioLogado; var retorno = await mediator.Send(new GerarRelatorioCommand(TipoRelatorio.Boletim, filtroRelatorioBoletimDto, usuarioLogado)); unitOfWork.PersistirTransacao(); return(retorno); }
public async Task <bool> Handle(ValidaSeExisteUePorCodigoQuery request, CancellationToken cancellationToken) { if (repositorioUe.ObterPorCodigo(request.CodigoUe) == null) { throw new NegocioException("Não foi possível encontrar a UE"); } return(true); }
private FechamentoReabertura TransformarDtoEmEntidadeParaPersistencia(FechamentoReaberturaPersistenciaDto fechamentoReaberturaPersistenciaDto) { Dre dre = null; Ue ue = null; if (!string.IsNullOrEmpty(fechamentoReaberturaPersistenciaDto.DreCodigo)) { dre = repositorioDre.ObterPorCodigo(fechamentoReaberturaPersistenciaDto.DreCodigo); if (dre == null) { throw new NegocioException("Não foi possível localizar a Dre."); } } if (!string.IsNullOrEmpty(fechamentoReaberturaPersistenciaDto.UeCodigo)) { ue = repositorioUe.ObterPorCodigo(fechamentoReaberturaPersistenciaDto.UeCodigo); if (ue == null) { throw new NegocioException("Não foi possível localizar a UE."); } } var tipoCalendario = repositorioTipoCalendario.ObterPorId(fechamentoReaberturaPersistenciaDto.TipoCalendarioId); if (tipoCalendario == null) { throw new NegocioException("Não foi possível localizar o Tipo de Calendário."); } var fechamentoReabertura = new FechamentoReabertura() { Descricao = fechamentoReaberturaPersistenciaDto.Descricao, Fim = fechamentoReaberturaPersistenciaDto.Fim, Inicio = fechamentoReaberturaPersistenciaDto.Inicio }; fechamentoReabertura.AtualizarDre(dre); fechamentoReabertura.AtualizarUe(ue); fechamentoReabertura.AtualizarTipoCalendario(tipoCalendario); fechamentoReaberturaPersistenciaDto.Bimestres.ToList().ForEach(bimestre => { fechamentoReabertura.Adicionar(new FechamentoReaberturaBimestre() { Bimestre = bimestre }); }); return(fechamentoReabertura); }
private (Dre, Ue) ObterDreEUe(string codigoDre, string codigoUe) { Dre dre = null; if (!string.IsNullOrWhiteSpace(codigoDre)) { dre = repositorioDre.ObterPorCodigo(codigoDre.ToString()); } Ue ue = null; if (!string.IsNullOrWhiteSpace(codigoUe)) { ue = repositorioUe.ObterPorCodigo(codigoUe.ToString()); } return(dre, ue); }
public Ue ObterPorCodigo(string codigoUe) => repositorioUe.ObterPorCodigo(codigoUe);
public async Task <Ue> ObterPorCodigo(string codigoUe) => repositorioUe.ObterPorCodigo(codigoUe);