Example #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"));
        }
Example #2
0
 private void reserveProjects(ExcessDbContext context, int projectSamples, int reserveCount)
 {
     for (int i = projectSamples; i < reserveCount; i++)
     {
         var reserved = new Project {
             ID = i, IsSample = true
         };
         context.Projects.AddOrUpdate(reserved);
     }
 }
Example #3
0
 private void reserveProjectFiles(ExcessDbContext context, int projectFileSamples, int reserveCount)
 {
     for (int i = projectFileSamples; i < reserveCount; i++)
     {
         var reserved = new ProjectFile {
             ID = i
         };
         context.ProjectFiles.AddOrUpdate(reserved);
     }
 }
Example #4
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));
        }
Example #5
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));
        }