public IComandResult Alterar([FromBody] AlterarTipoOcorrenciaCommands command)
        {
            try
            {
                var result = (ComandResult)_tipoOcorrenciaHandler.Handle(command);

                this.Commit(result.Success);
                return(result);
            }
            catch (Exception)
            {
                return(null);
            }
        }
예제 #2
0
        public IComandResult Handle(AlterarTipoOcorrenciaCommands comand)
        {
            //verificar se tem notificação no comand
            if (!comand.IsValid())
            {
                return(new ComandResult(false, "Por favor corrija os campos abaixo", comand.Notifications));
            }

            var tipoOcorrencia = _repository.Existe(comand.Id);

            if (tipoOcorrencia != null)
            {
                tipoOcorrencia.Alterar(comand.Nome);
                _repository.Alterar(tipoOcorrencia);
            }
            else
            {
                return(new ComandResult(false, "Série não existe,tente novamente!!", new { }));
            }

            return(new ComandResult(true, "Dados Alterados com Sucesso!!", new { }));
        }