Exemplo n.º 1
0
 public IEnumerable<Question> GetListOfQuestion()
 {
     var ctx = new Context();
     List<Question> list = new List<Question>(); 
     ctx.Questions.ToList().ForEach(item=> list.Add(new Question(){ Text= item.Text, Id=item.Id}));
     return list;
 
 }
Exemplo n.º 2
0
 public async Task<IHttpActionResult> SubmitAnswer(Answer answerModel)
 {
     if (!ModelState.IsValid)
     {
         return BadRequest(ModelState);
     }
     try
     {
         var ctx = new Context();
         ctx.Answers.Add(answerModel);
         ctx.SaveChanges();
         return Ok();
     }
     catch
     {
         return BadRequest("Issue in saving");
     }
 }