0

I have a view model that consists of the following three fields:

  • StartDate
  • EndData
  • Status

The StartDate and the EndDate fields are stored in db and can be edited on UI. The Status field is computed on the server side and is read-only (it depends from the two dates, but this logic can be changed).

When I change the dates on the client side and send a PUT request, I want the Status to be updated on my page as well. I see couple of options how this might be implemented:

  1. Update the status immediately on the client. That does not look pretty right to me since I need to duplicate the status determining logic which is already part of the domain model.

  2. Re-read the model manually using a GET request after the updating. This can happen for instance if I receive the 205 Reset Content response.

  3. Return the new status or the whole model in the response of the PUT request. Might be an option but as far as I see it's recommended to return either 200 OK or 204 No Content status.

Community
  • 1
  • 1
Serhii Shushliapin
  • 2,528
  • 2
  • 15
  • 32

1 Answers1

0

Depends on the meaning of Status. If you need to show that the PUT was successful or not, then on the response you can update the Status. If you need extra information, then it would be wiser to have another GET request.

bbakiu
  • 281
  • 3
  • 11
  • Oh, it's a bit confusing. The `Status` here is not about whether the PUT is successful or not. It's just some value from the server side that needs to be updated on the client. – Serhii Shushliapin Mar 03 '15 at 13:04