fixed error on room floor update

Change-Id: I51cb58d9bdfc8fca64cbab37e1adde1d9ca2a30e
This commit is contained in:
Sebastian Marcet 2018-03-14 07:25:51 -03:00
parent fe462f2d33
commit d8a855f43a
3 changed files with 28 additions and 22 deletions

View File

@ -1187,7 +1187,6 @@ final class OAuth2SummitLocationsApiController extends OAuth2ProtectedController
$payload = Input::json()->all();
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
if (is_null($summit)) return $this->error404();
$payload['class_name'] = SummitAirport::ClassName;
$rules = [
'name' => 'sometimes|string|max:50',
'number' => 'sometimes|integer',
@ -1296,7 +1295,7 @@ final class OAuth2SummitLocationsApiController extends OAuth2ProtectedController
);
}
if(isset($payload['floor_id']))
if(!isset($payload['floor_id']))
$payload['floor_id'] = intval($floor_id);
$room = $this->location_service->updateVenueRoom($summit, $venue_id, $room_id, $payload);
@ -2179,7 +2178,7 @@ final class OAuth2SummitLocationsApiController extends OAuth2ProtectedController
);
}
$image = $this->location_service->updateLocationImage()
$image = $this->location_service->updateLocationImage
(
$summit,
$location_id,

View File

@ -825,33 +825,39 @@ final class LocationService implements ILocationService
)
);
}
$old_floor_id = $room->getFloorId();
$new_floor_id = $room->getFloorId();
$room = SummitLocationFactory::populate($room, $data);
SummitLocationFactory::populate($room, $data);
$floor = null;
if(isset($data['floor_id'])){
$old_floor_id = intval($room->getFloorId());
$new_floor_id = intval($data['floor_id']);
$floor = $venue->getFloor($new_floor_id);
if(is_null($floor)){
throw new EntityNotFoundException
(
trans
if($old_floor_id != $new_floor_id) {
$floor = $venue->getFloor($new_floor_id);
if (is_null($floor)) {
throw new EntityNotFoundException
(
'not_found_errors.LocationService.updateVenueRoom.FloorNotFound',
[
'floor_id' => $new_floor_id,
'venue_id' => $venue_id
]
)
);
}
trans
(
'not_found_errors.LocationService.updateVenueRoom.FloorNotFound',
[
'floor_id' => $new_floor_id,
'venue_id' => $venue_id
]
)
);
}
if($old_floor_id > 0){
// remove from old floor
$room->getFloor()->removeRoom($room);
$floor->addRoom($room);
}
$floor->addRoom($room);
}
}
$summit->addLocation($room);
$venue->addRoom($room);
// request to update order
if (isset($data['order']) && intval($data['order']) != $room->getOrder()) {

View File

@ -954,9 +954,10 @@ final class OAuth2SummitLocationsApiTest extends ProtectedApiTest
];
$data = [
'description' => 'Pyrmont Theatre',
'description' => 'Pyrmont Theatre Update',
'order' => 2,
'capacity' => 1000,
'floor_id' => 23
];
$headers = [