コード例 #1
0
        public string refreshValue()
        {
            using (var context = new evlilikTeklifContext())
            {
                var x = context.Questions.Where(i => i.isAnswered == true).ToList();
                if (x.Count() > 0)
                {
                    foreach (var item in x)
                    {
                        item.isAnswered           = false;
                        context.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                    }

                    context.SaveChanges();
                }
                return("success");
            }
        }
コード例 #2
0
 public string Answerquestion(AnswerModel model)
 {
     if (model.Answer != null)
     {
         using (var context = new evlilikTeklifContext())
         {
             var x = context.Questions.Where(i => i.number == model.QuestionNumber && i.answer == model.Answer.ToUpper()).FirstOrDefault();
             if (x != null)
             {
                 x.isAnswered           = true;
                 context.Entry(x).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                 context.SaveChanges();
                 return("success");
             }
             else
             {
                 throw new Exception("Yanlış cevap");
             }
         }
     }
     throw new Exception("Yanlış cevap");
 }