I have an App where I wish to import clothing items into a database. When the clothing stock has arrived to the clothing store, the user will scan the barcode on the delivery receipt and details of the delivery is displayed on the app. For example
Item Qty Stock No
Levi Jeans 30 4528
Nike 15 4521
Adidas 14 3526
My app is working so far where I created an array for the items and imported them into the database. The problem that I am having is all items imported are being duplicated where the item already exist in the database. So for example if there is already an entry for Nike and the current quantity is 3, when I import the new stock you will see 2 entries for Nike. Both displaying the same stock No, one with 3 items and the other for 15 whereby we need only need one entry displaying 18 items. This happens if I use the create service. When I use the update service to import the new if the first item on the import is a new item and not already existing in the database, then none of the items to be imported are imported (updated or created) on the database.
So what I need help on is if an array item exists on the database the quantity is updated on the existing item on the database. If the array item is new then a new entry is created on the database.
Can you help?