QuestionViewModel

What will a quiz be without some questions? Here's how we can deal with the QuestionViewModel.cs file that we need to add within the /ViewModels/ folder:

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

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

}
#endregion

#region Properties
public int Id { get; set; }
public int QuizId { 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; }
[JsonIgnore]
public DateTime CreatedDate { get; set; }
public DateTime LastModifiedDate { get; set; }
#endregion
}
}

As we can see, this is quite similar to the QuizViewModel, except that it has slightly different properties; one of these is the QuizId, which is rather obvious since each question will be related to its Quiz in a classic one-to-many relationship; each single Quiz will have multiple Questions.

..................Content has been hidden....................

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