December 2019
Intermediate to advanced
598 pages
12h 21m
English
Let's add validation to the request for posting an answer:
using System.ComponentModel.DataAnnotations;
public class AnswerPostRequest{ [Required] public int? QuestionId { get; set; } [Required] public string Content { get; set; } ...}
So, we require the QuestionId to be supplied along with the answer content.
Notice the ? after the int type on the QuestionId property.
So, why does QuestionId need to be able to hold a null value? This is because an ...
Read now
Unlock full access