public async Task <ActionResult> UpdateGarage(UpdateGarageDto updateGarageDto) { try { await _garageService.UpdateGarage(updateGarageDto); return(Response.Ok()); } catch (BaseException e) { _logger.LogInformation(ExceptionHandlerHelper.ExceptionMessageStringToLogger(e)); return(Response.HandleExceptions(e)); } catch (Exception e) { _logger.LogError(e, GetType().Name + "." + MethodBase.GetCurrentMethod().Name); return(Response.InternalServerError()); } }
public async Task UpdateGarage(UpdateGarageDto updateGarageDto) { //Valido los campos necesarios Throws.ThrowIfNull(updateGarageDto, new BadRequestException("Los parametros son nulos.")); Throws.ThrowIfNull(updateGarageDto.altura_maxima, new BadRequestException("AlturaMaxima esta vacio.")); Throws.ThrowIfEmpty(updateGarageDto.coordenadas, new BadRequestException("coordenadas esta vacio.")); Throws.ThrowIfEmpty(updateGarageDto.direccion, new BadRequestException("direccion esta vacio.")); Throws.ThrowIfNull(updateGarageDto.localidad_garage, new BadRequestException("localidad garage esta vacio.")); Throws.ThrowIfNull(updateGarageDto.lugar_autos, new BadRequestException("lugar autos esta vacio.")); Throws.ThrowIfNull(updateGarageDto.lugar_bicicletas, new BadRequestException("lugar bicicletas esta vacio.")); Throws.ThrowIfNull(updateGarageDto.lugar_camionetas, new BadRequestException("lugar camionetas esta vacio.")); Throws.ThrowIfNull(updateGarageDto.lugar_camionetas, new BadRequestException("lugar camionetas esta vacio.")); Throws.ThrowIfNull(updateGarageDto.lugar_motos, new BadRequestException("lugar motos esta vacio.")); Throws.ThrowIfEmpty(updateGarageDto.nombre_garage, new BadRequestException("nombre garage esta vacio.")); Throws.ThrowIfEmpty(updateGarageDto.telefono, new BadRequestException("telefono esta vacio.")); Throws.ThrowIfNull(updateGarageDto.garage_id, new BadRequestException("garage_id esta vacio.")); //hago el update await _guardameLugarDacService.UpdateGarage(updateGarageDto); }
public async Task UpdateGarage(UpdateGarageDto updateGarageDto) { using (SqlCommand oCommand = await base.GetCommandAsync()) { try { oCommand.CommandText = @"Update garages set [nombre_garage] = @nombre_garage, [direccion] = @direccion, [coordenadas] = @coordenadas, [localidad_garage] = @localidad_garage, [telefono] = @telefono, [lugar_autos] = @lugar_autos, [lugar_motos] = @lugar_motos, [lugar_camionetas] = @lugar_camionetas, [lugar_bicicletas] = @lugar_bicicletas, [altura_maxima] = @altura_maxima where [garage_id] = @garage_id;" ; oCommand.AddParameter("garage_id", DbType.Int32, updateGarageDto.garage_id); oCommand.AddParameter("altura_maxima", DbType.Decimal, updateGarageDto.altura_maxima); oCommand.AddParameter("coordenadas", DbType.String, updateGarageDto.coordenadas); oCommand.AddParameter("telefono", DbType.String, updateGarageDto.telefono); oCommand.AddParameter("direccion", DbType.String, updateGarageDto.direccion); oCommand.AddParameter("localidad_garage", DbType.Int32, updateGarageDto.localidad_garage); oCommand.AddParameter("lugar_autos", DbType.Int32, updateGarageDto.lugar_autos); oCommand.AddParameter("lugar_bicicletas", DbType.Int32, updateGarageDto.lugar_bicicletas); oCommand.AddParameter("lugar_camionetas", DbType.Int32, updateGarageDto.lugar_camionetas); oCommand.AddParameter("lugar_motos", DbType.Int32, updateGarageDto.lugar_motos); oCommand.AddParameter("nombre_garage", DbType.String, updateGarageDto.nombre_garage); await oCommand.ExecuteNonQueryAsync(); } catch (Exception ex) { _logger.LogError(ex, GetType().Name + "." + MethodBase.GetCurrentMethod().Name); throw new AggregateException(_classFullName + ".UpdateGarage(GarageDto garageDto)", ex); } finally { if (!TransactionOpened()) { base.CloseCommand(); } } } }
public async Task UpdateGarage(UpdateGarageDto updateGarageDto) { await _guardameLugarDac.UpdateGarage(updateGarageDto); }