1
I have a question about who’s responsible (back or front) in my case, I have a list on front which is sent to the backend save or inactivate the record:
[{ idTabela: 2, codKit: "kitCopleto", dataInicio: "2019-01-01", dataFim: "2019-01-01"}, { idTabela: null, codKit: "kitCopleto2", dataInicio: "2019-01-01", dataFim: ""}]
Currently when the user deletes an item from that list, instead of setting the property DataFim
with today’s date, we are physically deleting the item from the list and sending to backend.
Thus the backend is being responsible for performing a query in the database, bringing all items and comparing with the list you received from front, if the item has IdTabela
so it already exists in the database and should be changed, otherwise it should be done the insert
.
Every time I have to perform one select
at the base bringing all the items, this would not be little performatic?
It would be better to work with 2 lists on front and send to the backend the list already with the dataFim
items that were deleted by the user?
When you delete information that is rescued from a repository any your repository needs to know of this deletion ... after it knows you send to the front that the list does not exist such item ...
– novic
Ola Virgilio! Thanks for the answer, but this would only be possible if each deleted item was made a request...However, by definition UX was determined that it would only be deleted in fact after the user click on "finish"...that way, I am obliged to perform a single request by sending a list of items.
– Paulo Bruno Soares Santos
You only send the deleted items, and after return from the backend remove from the front !!!
– novic
Virgilio, the problem is a little bigger. The user can re-enter the same item that deleted or insert new items...so I can’t just forward the deleted ones, I should forward the new tbm records and always be checking if the inserted item has already been deleted, if the item was already registered or if it isif of only one Insert... Somewhere there must be this complexity...my doubt is whether the front would be responsible or the backend. OBS: I don’t need to wait for the backend to return...as the user clicks to immediately delete the item some from the list.
– Paulo Bruno Soares Santos
If your goal is when you record by the button then you know how to solve and you are already doing so, I would not do so I would each with its responsibility, but apparently you can not... So the rule is clear
– novic
@Paulobrunosoaressantos Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero