コード例 #1
0
        public async Task <IActionResult> Post([FromBody] AnexoBeneficio anexoBeneficio)
        {
            try
            {
                _service.Add(anexoBeneficio);

                return(Created($"/api/anexoBeneficio/getById/{anexoBeneficio.Id}", anexoBeneficio));
            }
            catch (Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de Dados falhou"));
            }
            return(BadRequest());
        }
コード例 #2
0
        public async Task <IActionResult> Put(int id, [FromBody] AnexoBeneficio anexoBeneficio)
        {
            try
            {
                var results = await _service.GetAsyncById(id);

                if (results == null)
                {
                    return(NotFound());
                }
                _service.Update(id, anexoBeneficio);

                return(Created($"/api/anexoBeneficio/getById/{anexoBeneficio.Id}", anexoBeneficio));
            }
            catch (Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de Dados falhou"));
            }
        }
コード例 #3
0
 public void Update(int id, AnexoBeneficio entity)
 {
     _repository.Update(id, entity);
 }
コード例 #4
0
 public void Add(AnexoBeneficio entity)
 {
     _repository.Add(entity);
 }