I develop winforms app. One of my forms accepts user input and calls a web service to add the input into the DB. The input must be unique, however I have no way of knowing if it is unique in the client side. I send the input to the WS and it is responsible of either adding it to the DB or informing the client that the input already exists.
What is the correct way to implement that?
Should I make two calls to the WS, one to know if it is unique and one to insert into the DB? I sense synchronization issues + two round trips across boundary.
Should I return an enum, ValueNotUnique and ValueInsertedSuccessfully?
Or perhaps throw an exception? That sounds not performance wise, plus I don't like using exceptions for things I already know that might not work.
Is there a nice design to this mess? Help appreciated, thanks in advance!