Beispiel #1
0
        public ActionResult AddDSLTest(string name, string contents)
        {
            var project = Session["projectId"] as int?;
            if (project == null)
                return HttpNotFound(); //td: right error

            ExcessDbContext _db = new ExcessDbContext();

            var result = new DSLTest
            {
                ID        = Guid.NewGuid(),
                ProjectID = (int)project,
                Caption   = name,
                Contents  = contents
            };

            _db.DSLTests.Add(result);
            _db.SaveChanges();

            return Json(result, JsonRequestBehavior.AllowGet);
        }
Beispiel #2
0
        public ActionResult UpdateDSLTest(string id, string contents)
        {
            var project = Session["projectId"] as int?;
            if (project == null)
                return HttpNotFound(); //td: right error

            Guid testId;
            if (!Guid.TryParse(id, out testId))
                return HttpNotFound(); //td: right error

            ExcessDbContext _db = new ExcessDbContext();
            var result = _db.DSLTests
                .Where(test => test.ID == testId)
                .FirstOrDefault();

            if (result == null)
                return HttpNotFound(); //td: right error

            result.Contents = contents;
            _db.SaveChanges();

            return Content("ok");
        }
Beispiel #3
0
        public ActionResult GetDSLTests()
        {
            var project = Session["projectId"] as int?;
            if (project == null)
                project = Session["SampleProjectId"] as int?;

            if (project == null)
                return HttpNotFound(); //td: right error

            //td: !!! entity project
            ExcessDbContext _db = new ExcessDbContext();
            var result = _db.DSLTests.Where( test => test.ProjectID == project);

            return Json(result, JsonRequestBehavior.AllowGet);
        }