public async Task <IActionResult> Post([FromBody] BeneficioServidor beneficioServidor)
        {
            try
            {
                _beneficioServidorService.Add(beneficioServidor);

                return(Created($"/api/beneficio/{beneficioServidor.Id}", beneficioServidor));
            }
            catch (Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de Dados falhou"));
            }
            return(BadRequest());
        }
Exemplo n.º 2
0
        public ICommandResult Handle(CreateBeneficioServidorCommand command)
        {
            try
            {
                var beneficio = new BeneficioServidor(nome: command.Nome, cpf: command.CPF, orgao: command.Orgao, matricula: command.Matricula, ESetoresTramitacao.Setorial_Servidor);
                _uow.GetRepository <BeneficioServidor>()
                .Save(beneficio);
                _uow.SaveChanges();

                GravarTramitacao(beneficio, ESetoresTramitacao.Setorial_Servidor, ESetoresTramitacao.Setorial_Servidor);

                return(new CommandResult(success: true, message: "Servidor salvo com sucesso", data: command.Notifications));
            }
            catch (Exception ex)
            {
                return(new CommandResult(success: false, message: ex.Message, data: null));
            }
        }
        public async Task <IActionResult> Put(int id, [FromBody] BeneficioServidor beneficioServidor)
        {
            try
            {
                var results = await _beneficioServidorService.GetAsyncById(id);

                if (results == null)
                {
                    return(NotFound());
                }

                _beneficioServidorService.Update(id, beneficioServidor);

                return(Created($"/api/beneficio/{beneficioServidor.Id}", beneficioServidor));
            }
            catch (Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de Dados falhou"));
            }
        }
Exemplo n.º 4
0
        private void GravarTramitacao(BeneficioServidor beneficio, ESetoresTramitacao setorAnterior, ESetoresTramitacao tramitacao)
        {
            try
            {
                var documentoTramitacao = new ProcessoTramitacao(

                    servidorId: beneficio.Id,
                    data: DateTime.Now,
                    origem: setorAnterior,
                    destino: tramitacao,
                    usuario: _user.Name == null ? "Carlos Eduardo" : _user.Name); { }


                _uow.GetRepository <ProcessoTramitacao>()
                .Save(entity: documentoTramitacao);

                _uow.SaveChanges();
            }
            catch (Exception ex)
            {
            }
        }
 public void Update(int id, BeneficioServidor entity)
 {
     _beneficioServidorRepository.Update(id, entity);
 }
 public void Add(BeneficioServidor entity)
 {
     _beneficioServidorRepository.Add(entity);
 }