예제 #1
0
        public ActionResult DeleteModule(int?id)
        {
            TestModuleService.EnableTracking();
            var module = TestModuleService.GetByPK(id.Value);

            EditTestPermission(module.TestId);
            TestModuleService.DeleteAndSubmit(module);
            return(Json("ok"));
        }
예제 #2
0
        public ActionResult EditTest(TestEditVM model)
        {
            SetUpdateDateAndLastChanger(model.Test);

            if (!LinqToSqlValidator.Validate(ModelState, model.Test))
            {
                return(ErrorJson());
            }
            TestService.EnableTracking();
            if (model.Test.Id == 0)
            {
                model.Test.Status    = TestStatus.Edit;
                model.Test.Author_TC = User.Employee_TC ?? Employees.Specweb;
                model.Test.CompanyId = User.CompanyID;
                EntityUtils.SetModulePercents(model.Test.TestPassRule, model.ModulePercents);
                TestService.InsertAndSubmit(model.Test);
                TestModuleService.EnableTracking();
                TestModuleService.CreateModulesFromCourse(model.Test);
                return(UrlJson(Url.Action <TestEditController>(c => c.EditTest(model.Test.Id))));
            }
            TestService.LoadWith(x => x.TestPassRule);
            var test        = TestService.GetByPK(model.Test.Id);
            var isNewCourse = test.CourseTCList != model.Test.CourseTCList;

            EditTestPermission(test.Id);
            test.Update(model.Test,
                        x => x.Description,
                        x => x.Name,
                        x => x.CourseTCList
                        );
            var newTestPassRule = model.Test.TestPassRule;

            test.TestPassRule.UpdateBy(newTestPassRule);
            EntityUtils.SetModulePercents(test.TestPassRule, model.ModulePercents);
            TestService.SubmitChanges();
            if (isNewCourse)
            {
                TestModuleService.EnableTracking();
                TestModuleService.CreateModulesFromCourse(model.Test);
            }
            return(Json("ok"));
        }
예제 #3
0
 public ActionResult EditModule(TestModule model)
 {
     if (!LinqToSqlValidator.Validate(ModelState, model))
     {
         return(ErrorJson());
     }
     EditTestPermission(model.TestId);
     TestModuleService.EnableTracking();
     if (model.Id == 0)
     {
         TestModuleService.InsertAndSubmit(model);
         return(UrlJson(Url.TestEdit().Urls.EditModule(model.TestId, model.Id)));
     }
     else
     {
         var module = TestModuleService.GetByPK(model.Id);
         module.Update(model, x => x.Name);
         TestModuleService.SubmitChanges();
     }
     return(Json("ok"));
 }