public void UpdateOutput(Participant model)
 {
     using (DBLearningModel db = new DBLearningModel())
     {
         db.Entry(model).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
 public Participant Insert(Participant model)
 {
     using (DBLearningModel db = new DBLearningModel())
     {
         db.Participant.Add(model);
         db.SaveChanges();
         return(model);
     }
 }
Пример #3
0
 public HttpResponseMessage GetAnswers(int[] qIDs)
 {
     using (DBLearningModel db = new DBLearningModel())
     {
         var result = db.Question
                      .AsEnumerable()
                      .Where(y => qIDs.Contains(y.QnID))
                      .OrderBy(x => { return(Array.IndexOf(qIDs, x.QnID)); })
                      .Select(z => z.Answer)
                      .ToArray();
         return(this.Request.CreateResponse(HttpStatusCode.OK, result));
     }
 }
Пример #4
0
 public HttpResponseMessage GetQuestions()
 {
     using (DBLearningModel db = new DBLearningModel())
     {
         //retourneer alle koloms van de tabel behalve de laatste kolom (answer)
         //dit doet die random. Nog wijzigen naar een bepaalde volgorde
         var Qns = db.Question
                   .Select(x => new { QnID = x.QnID, Qn = x.Qn, ImageName = x.ImageName, x.Option1, x.Option2, x.Option3 })
                   .OrderBy(y => Guid.NewGuid())
                   .ToArray();
         //format questions array
         var updated = Qns.AsEnumerable()
                       .Select(x => new
         {
             QnID      = x.QnID,
             Qn        = x.Qn,
             ImageName = x.ImageName,
             Options   = new string[] { x.Option1, x.Option2, x.Option3 }
         }).ToList();
         //then return the questions
         return(this.Request.CreateResponse(HttpStatusCode.OK, updated));
     }
 }