Class ShoppingListService
java.lang.Object
ntnu.idatt2016.v233.SmartMat.service.group.ShoppingListService
Service for the shopping list
- Version:
- 1.1
- Author:
- Stian Lyng, Birk
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddProductToShoppingList
(long ean, long shoppingListId) Adds a product to a shopping listvoid
deleteShoppingListById
(long id) Deletes a shopping list by its IDGets all shopping listslong
getGroupIdByShoppingListId
(long shoppinglistId) Get group id by shoppinglist idgetShoppingListByGroupId
(long id) Gets a shopping list by its group IDgetShoppingListById
(long id) Gets a shopping list by its IDboolean
isUserInShoppinglist
(long id, String name) Check if user can edit/get shoppinglistremoveProductFromShoppingList
(long ean, long shoppingListId) Removes a product from a shopping list
-
Constructor Details
-
ShoppingListService
public ShoppingListService()
-
-
Method Details
-
getShoppingListById
Gets a shopping list by its ID- Parameters:
id
- the ID of the shopping list- Returns:
- an optional containing the shopping list if it exists
-
getShoppingListByGroupId
Gets a shopping list by its group ID- Parameters:
id
- the ID of the group- Returns:
- an optional containing the shopping list if it exists
-
getAllShoppingLists
Gets all shopping lists- Returns:
- an optional containing a list of all shopping lists if they exist
-
deleteShoppingListById
public void deleteShoppingListById(long id) Deletes a shopping list by its ID- Parameters:
id
- the ID of the shopping list
-
addProductToShoppingList
Adds a product to a shopping list- Parameters:
ean
- the ean of the product to addshoppingListId
- the id of the shopping list to add the product to- Returns:
- the product that was added to the shopping list
-
removeProductFromShoppingList
Removes a product from a shopping list- Parameters:
ean
- the ean of the product to removeshoppingListId
- the id of the shopping list to remove the product from- Returns:
- the shopping list that the product was removed from
-
isUserInShoppinglist
Check if user can edit/get shoppinglist- Parameters:
id
- id of shoppinglistname
- name of user- Returns:
- true if user is in shoppinglist, false if not
-
getGroupIdByShoppingListId
public long getGroupIdByShoppingListId(long shoppinglistId) Get group id by shoppinglist id- Parameters:
shoppinglistId
- id of shoppinglist- Returns:
- id of group
-