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

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

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

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

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