Beispiel #1
0
 public object GetQuestion()
 {
     try
     {
         questionTab objQues = new questionTab();
         return(objEntity.questionTabs);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public object AddQues(questionTab question)
        {
            var result = db.questionTabs.Where(s => s.ques == question.ques).FirstOrDefault();


            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                if (result == null)
                {
                    db.questionTabs.Add(new questionTab()
                    {
                        ques   = question.ques,
                        opt1   = question.opt1,
                        opt2   = question.opt2,
                        opt3   = question.opt3,
                        opt4   = question.opt4,
                        answer = question.answer,
                        tstId  = question.tstId,
                        mark   = question.mark
                    });
                    int x = db.SaveChanges();
                    return(x);
                }
                else
                {
                    return("Exists");
                }
            }
            catch (Exception)
            {
                throw;
            }
        }