Make controller helper pickRestaurantFromRestaurants() generic
This commit is contained in:
@@ -28,11 +28,10 @@ static bool checkAccess(std::shared_ptr<User> user, const std::string& userWithA
|
||||
return true;
|
||||
}
|
||||
|
||||
static restaurants::iterator pickRestaurantFromRestaurants(RestaurantOwner& restaurantOwner)
|
||||
static restaurants::iterator pickRestaurantFromRestaurants(restaurants& ownerRestaurants)
|
||||
{
|
||||
util::clear();
|
||||
int restaurantIndex = 1, restaurantChoiceIndex;
|
||||
restaurants& ownerRestaurants = restaurantOwner.getRestaurants();
|
||||
if (ownerRestaurants.empty())
|
||||
{
|
||||
std::cout << "You do not own any Restaurants!\n";
|
||||
@@ -307,7 +306,7 @@ void FoodDeliveryController::updateRestaurantStatus() const
|
||||
return;
|
||||
}
|
||||
RestaurantOwner& restaurantOwner = *(std::dynamic_pointer_cast<RestaurantOwner>(m_authenticatedUser));
|
||||
restaurants::iterator restaurantIterator = pickRestaurantFromRestaurants(restaurantOwner);
|
||||
restaurants::iterator restaurantIterator = pickRestaurantFromRestaurants(restaurantOwner.getRestaurants());
|
||||
if (restaurantIterator != restaurantOwner.getRestaurants().end())
|
||||
{
|
||||
if (restaurantIterator->second->getStatus() == true)
|
||||
@@ -353,7 +352,7 @@ void FoodDeliveryController::listMenuItems() const
|
||||
return;
|
||||
}
|
||||
RestaurantOwner& restaurantOwner = *(std::dynamic_pointer_cast<RestaurantOwner>(m_authenticatedUser));
|
||||
restaurants::iterator restaurantIterator = pickRestaurantFromRestaurants(restaurantOwner);
|
||||
restaurants::iterator restaurantIterator = pickRestaurantFromRestaurants(restaurantOwner.getRestaurants());
|
||||
if (restaurantIterator != restaurantOwner.getRestaurants().end())
|
||||
{
|
||||
util::clear();
|
||||
@@ -400,7 +399,7 @@ void FoodDeliveryController::addMenuItem() const
|
||||
return;
|
||||
}
|
||||
RestaurantOwner& restaurantOwner = *(std::dynamic_pointer_cast<RestaurantOwner>(m_authenticatedUser));
|
||||
restaurants::iterator restaurantIterator = pickRestaurantFromRestaurants(restaurantOwner);
|
||||
restaurants::iterator restaurantIterator = pickRestaurantFromRestaurants(restaurantOwner.getRestaurants());
|
||||
if (restaurantIterator != restaurantOwner.getRestaurants().end())
|
||||
{
|
||||
util::clear();
|
||||
@@ -438,7 +437,7 @@ void FoodDeliveryController::removeMenuItem() const
|
||||
return;
|
||||
}
|
||||
RestaurantOwner& restaurantOwner = *(std::dynamic_pointer_cast<RestaurantOwner>(m_authenticatedUser));
|
||||
restaurants::iterator restaurantIterator = pickRestaurantFromRestaurants(restaurantOwner);
|
||||
restaurants::iterator restaurantIterator = pickRestaurantFromRestaurants(restaurantOwner.getRestaurants());
|
||||
if (restaurantIterator != restaurantOwner.getRestaurants().end())
|
||||
{
|
||||
menuItems& restaurantMenuItems = restaurantIterator->second->getMenuItems();
|
||||
|
||||
Reference in New Issue
Block a user