public ActionResult GetForEdit(long id) { Response.Cache.SetMaxAge(new TimeSpan(0)); CreatingTest res = testService.GetTestForEditById(id); return(Json(res, JsonRequestBehavior.AllowGet)); }
public CreatingTest PutChangeTest(long id, CreatingTest mod) { var res = testservice.CreateOrEditTest(mod); if (res == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(res); }
// GET: Default public ActionResult Index(long subjectId, string title, HttpPostedFileBase file) { string line; CreatingTest res = new CreatingTest(); res.Questions = new List <CreatingTestQuestion>(); res.Title = title; res.SubjectId = subjectId; CreatingTestQuestion tq = null; CreatingTestAnswer ta = null; if (file.ContentLength > 0) { StreamReader c = new StreamReader(file.InputStream); while (!c.EndOfStream) { line = c.ReadLine(); if (line.Length > 0) { if (line.IndexOf("1::") > -1) { if (tq != null) { res.Questions.Add(tq); } tq = new CreatingTestQuestion(); tq.Name = line.Substring(line.IndexOf("::") + 2, line.IndexOf("::", 3) + 2); tq.Text = line.Substring(line.IndexOf("::", 3) + 2); tq.Answers = new List <CreatingTestAnswer>(); tq.IsRemoved = false; continue; } ta = new CreatingTestAnswer(); ta.Text = line.Substring(1); if (line[0] == '=') { ta.IsRight = true; } if (tq != null) { tq.Answers.Add(ta); } } } if (tq != null) { res.Questions.Add(tq); } c.Close(); } return(Json(testservice.CreateOrEditTest(res))); }
public ActionResult PutChangeTest(CreatingTest mod) { return(Json(testService.CreateOrEditTest(mod))); }