Пример #1
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"));
        }
Пример #2
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));
        }