AnswerViewModel

The Answers have with their Question the same one-to-many relationship that Questions have with their Quiz, hence the AnswerViewModel that we need to add will be quite similar to the QuestionViewModel:

using Newtonsoft.Json; 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace TestMakerFreeWebApp.ViewModels
{
[JsonObject(MemberSerialization.OptOut)]
public class AnswerViewModel
{
#region Constructor
public AnswerViewModel()
{

}
#endregion

#region Properties
public int Id { get; set; }
public int QuizId { get; set; }
public int QuestionId { get; set; }
public string Text { get; set; }
public string Notes { get; set; }
[DefaultValue(0)]
public int Type { get; set; }
[DefaultValue(0)]
public int Flags { get; set; }
[DefaultValue(0)]
public int Value{ get; set; }
[JsonIgnore]
public DateTime CreatedDate { get; set; }
public DateTime LastModifiedDate { get; set; }
#endregion
}
}

As we can see, there are only two significant differences:

  • We added a property, that references the QuestionId that represents the Question the Answer is related to
  • We added a Value property, that we'll use later to give a score value to each answer
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.72.176