public async Task <ActionResult <TipoInfraccionDTO> > insertarInfracciones(TipoInfraccionDTO tipoInfraccion) { var infra = await _apiService.InsertarInfraccion(tipoInfraccion); if (infra == null) { return(BadRequest()); } return(Ok(infra)); }
public async Task <TipoInfraccionDTO> InsertarInfraccion(TipoInfraccionDTO infraccion) { var inf = await _infraccionRepo.GetByNombreAsync(infraccion.Nombre); if (inf != null) { throw new ApiException("La Infraccion ya existe"); } _infraccionRepo.InsertarInfraccion(new TipoInfraccion(infraccion.Nombre, infraccion.Descripcion, infraccion.PuntosAdescontar)); var res = await _infraccionRepo.Complete(); if (res <= 0) { throw new ApiException("Error al guardar la infraccion"); } return(infraccion); }