예제 #1
0
        public ActionResult CreateQuestion(Question question, int TestID)
        {
            var model = new Question();
            DataContext _db = new DataContext();
            ((Test)_db.Test.Find(TestID)).Questions.Add(question);
            _db.SaveChanges();

            return RedirectToAction("CreateQuestion");
        }
예제 #2
0
        public void AddQuestion()
        {
            string text = Request.Form["text"];
            int test_id = Convert.ToInt32(Request.Form["test_id"]);

            DataContext db = new DataContext();
            Question q = db.Question.Create();
            q.GivenQuestion = text;
            q.TestID = test_id;

            db.Test.Find(test_id).Questions.Add(q);
            if(db.SaveChanges() > 0)
            {
                Response.Write(q.QuestionID.ToString());
                Response.End();
            }
            else
            {
                Response.Write("Fail");
                Response.End();
            }
        }
예제 #3
0
        public ActionResult CreateQuestion(Test test)
        {
            @ViewBag.TestID = test.TestID;
            DataContext _db = new DataContext();
            //_db.Test.Find(test.TestID).

            //context.Entry(book).Collection(b => b.Reviews).Query().Take(20).Load();

            //_db.Entry(test).Collection(x => x.Questions).Query().Load();

            //context.Shops.Include(s => s.ShopFacilities.Select(f => f.Facility))
            //  .First(x => x.Id == id);

            //context.Shops.Include(s => s.ShopFacilities.Select(f => f.Facility))
            //  .First(x => x.Id == id);
            //test = _db.Test.Include(x => x.Questions.Select(f => f.Test)).Take(20);

            test.Questions = _db.Question.Where(x => x.TestID == test.TestID).ToList();

            //_db.Test.
            //_db.Test.
            return View(test);
        }
예제 #4
0
        //GET
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";
            DataContext _db = new DataContext();
            _db.Test.First();

            return View();
        }
예제 #5
0
 public ActionResult Index(Test test)
 {
     DataContext _db = new DataContext();
     _db.Test.Add(test);
     _db.SaveChanges();
     return RedirectToAction("CreateQuestion", test);
 }
예제 #6
0
 public ActionResult CreateAnswer(Answer answer)
 {
     DataContext _db = new DataContext();
     //_db.Question.Answers.Add();
     return RedirectToAction("Index");
 }