0

I have a User table where I keep the profile information of the user along with some system generated columns and password.

I am using a model to query the database and send the result to the user. User modifies the profile information and send the request which I am using the same Model to deserialize. But I don't want the user to change those system generated fields.

What should I do?

4
  • I don't understand your question? If you don't want a user to modify some fields why are you exposing them to the user? Commented Nov 16, 2016 at 7:22
  • @DawidRutkowski They should be able to view the values - Read-Only fields. Commented Nov 16, 2016 at 7:49
  • Then simply disable the edition of those fields on the client side. You might also reset changes in those fields (or simply don't update them) on the server side when user will submit his changes. Commented Nov 16, 2016 at 8:04
  • @DawidRutkowskiThanks. This is precisely what i am doing right now but I thought there may be a better way to do by putting some annotations on model fields. Commented Nov 16, 2016 at 8:08

1 Answer 1

2

Regarding the Data Annotation attributes - try marking Property with ReadOnly attribute.

[ReadOnly(true)]
public decimal BodyMassIndex { get; private set; }

Look here for more details.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.