/// <summary> /// Cadastra uma agenda /// </summary> /// <param name="agendaCadastro">Cadastro de agenda</param> public void CadastrarAgenda(Entidades.Agenda.Agenda agendaCadastro) { if (agendaCadastro == null) { throw new ArgumentException("Os dados da agenda são obrigatórios."); } if (agendaCadastro.DataInicio < Constantes.DateTimeNow()) { throw new ArgumentException("Data/hora de início não pode ser menor que o dia/hora atual"); } if (agendaCadastro.DataFim < Constantes.DateTimeNow()) { throw new ArgumentException("Data/hora de término não pode ser menor que o dia atual"); } if (agendaCadastro.DataInicio > agendaCadastro.DataFim) { throw new ArgumentException("A data de início não pode ser maior que a data de término"); } if (agendaCadastro.DataInicio == agendaCadastro.DataFim && agendaCadastro.DataInicio.TimeOfDay > agendaCadastro.DataFim.TimeOfDay) { throw new ArgumentException("O horário de início não pode ser maior que o horário de término"); } if (agendaCadastro.DataInicio == agendaCadastro.DataFim && agendaCadastro.DataInicio.TimeOfDay == agendaCadastro.DataFim.TimeOfDay) { throw new ArgumentException("O horário de início e término não podem ser iguais"); } if (_AgendaRepository.AgendaJaCadastrada( agendaCadastro.DataInicio, agendaCadastro.DataFim, agendaCadastro.IdEndereco, agendaCadastro.IdUsuario) ) { throw new Exception("Já existe uma agenda cadastrada para a(s) data(s) e horário(s) informado(s)."); } _AgendaRepository.CadastrarAgenda(agendaCadastro); }
/// <summary> /// Cadastra a agencia no banco /// </summary> /// <param name="agendaCadastro">Agencia para ser cadastrada</param> public void CadastrarAgenda(Entidades.Agenda.Agenda agendaCadastro) { _UnitOfWork.Executar( _UnitOfWork.MontaInsertPorAttributo(agendaCadastro).ToString() ); }