Example #1
0
        public async Task <ActionResult <DeporteViewModel> > PostDeporte(DeporteViewModel deporte)
        {
            if (deporte == null)
            {
                return(BadRequest());
            }

            var id = await _deporteService.Add(deporte);

            return(Created($"api/Deportes/{id}", deporte));
        }
Example #2
0
        public async Task <IActionResult> PutDeporte(int id, [FromBody] DeporteViewModel deporte)
        {
            if (deporte == null || id != deporte.Id)
            {
                return(BadRequest());
            }

            int val = await _deporteService.Update(deporte);

            if (val == 0)
            {
                return(StatusCode(304));
            }
            else if (val == -1)
            {
                return(StatusCode(412, "DbUpdateConcurrencyException"));
            }
            else
            {
                return(Accepted(deporte));
            }
        }