public void updateQuestion(_QuestionViewModel model)
 {
     using (ApplicationDbContext context = new ApplicationDbContext())
     {
         Question dbQuestion = context.Questions.Where(x => x.QuestionId == model.QuestionId).FirstOrDefault();
         dbQuestion.QuestionBody   = model.QuestionBody;
         dbQuestion.QuestionType   = model.QuestionType;
         dbQuestion.QuestionActive = model.QuestionActive;
         context.SaveChanges();
     }
 }
 public void AddQuestion(_QuestionViewModel model)
 {
     using (ApplicationDbContext context = new ApplicationDbContext())
     {
         Question dbQuestion = context.Questions.Create();
         dbQuestion.QuestionBody = model.QuestionBody;
         dbQuestion.QuestionType = model.QuestionType;
         dbQuestion.CampaignId   = model.CampaignId;
         dbQuestion.IsOn         = model.QuestionActive;
         context.Questions.Add(dbQuestion);
         context.SaveChanges();
     }
 }
示例#3
0
 public IHttpActionResult Post(_QuestionViewModel model)
 {
     _adapter.AddQuestion(model);
     return(Ok());
 }
示例#4
0
 public IHttpActionResult Put(_QuestionViewModel model)
 {
     _adapter.updateQuestion(model);
     return(Ok());
 }
示例#5
0
        public IHttpActionResult Get(int Id)
        {
            _QuestionViewModel model = _adapter.GetQuestion(Id);

            return(Ok(model));
        }