Пример #1
0
        public IComandResult Handle(AlterarHorarioRotinaCommands comand)
        {
            //verificar se tem notificação no comand
            if (!comand.IsValid())
            {
                return(new ComandResult(false, "Por favor corrija os campos abaixo", comand.Notifications));
            }



            var horarioRotina = _repository.Existe(comand.HorarioRotinaId);

            if (horarioRotina != null)
            {
                var rotina = _rotinaRepository.Existe(horarioRotina.RotinaId, true);

                if (rotina != null)
                {
                    horarioRotina.Alterar(comand.Conteudo, comand.DiaSemanaId);
                    _repository.Alterar(horarioRotina);
                }
                else
                {
                    return(new ComandResult(false, "Não existe nenhuma rotina associado a esse horário!!", new { }));
                }
            }
            else
            {
                return(new ComandResult(false, "HorárioRotina não existe,tente novamente!!", new { }));
            }

            return(new ComandResult(true, "Dados Alterados com Sucesso!!", new { }));
        }
Пример #2
0
        public IComandResult Alterar([FromBody] AlterarHorarioRotinaCommands command)
        {
            try
            {
                var result = (ComandResult)_horarioRotinaHandler.Handle(command);

                this.Commit(result.Success);
                return(result);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }