/// <summary> /// Validates the curriculum chapter. /// </summary> /// <param name="data">The curriculum chapter.</param> /// <returns></returns> public ValidationStatus ValidateCurriculumChapter(CurriculumChapter data) { var validationStatus = new ValidationStatus(); ValidateDate(data.StartDate, data.EndDate, validationStatus); return validationStatus; }
/// <summary> /// Validates the curriculum chapter. /// </summary> /// <param name="data">The curriculum chapter.</param> /// <returns></returns> public ValidationStatus ValidateCurriculumChapter(CurriculumChapter data) { ValidationStatus validationStatus = new ValidationStatus(); ValidateDate(data.StartDate, data.EndDate, validationStatus); //TODO: check topic timelines and curriculum timelines! return validationStatus; }
public void UpdateCurriculumChapter(CurriculumChapter curriculumChapter) { var db = this.GetDbContext(); var oldCurriculumChapter = GetCurriculumChapter(db, curriculumChapter.Id); oldCurriculumChapter.StartDate = curriculumChapter.StartDate; oldCurriculumChapter.EndDate = curriculumChapter.EndDate; db.SubmitChanges(); var curriculum = GetCurriculum(db, oldCurriculumChapter.CurriculumRef); curriculum.IsValid = this.IsCurriculumValid(curriculum); db.SubmitChanges(); }
public int AddCurriculum(Curriculum curriculum) { var db = this.GetDbContext(); curriculum.IsDeleted = false; curriculum.IsValid = true; db.Curriculums.InsertOnSubmit(curriculum); db.SubmitChanges(); // add corresponding curriculum chapters var chapters = this.GetChapters(curriculum.DisciplineRef); foreach (var chapter in chapters) { var curriculumChapter = new CurriculumChapter { ChapterRef = chapter.Id, CurriculumRef = curriculum.Id }; this.AddCurriculumChapter(curriculumChapter); } return curriculum.Id; }
public int AddCurriculumChapter(CurriculumChapter curriculumChapter) { var db = this.GetDbContext(); curriculumChapter.IsDeleted = false; db.CurriculumChapters.InsertOnSubmit(curriculumChapter); var curriculum = GetCurriculum(db, curriculumChapter.CurriculumRef); if (curriculumChapter.StartDate < curriculum.StartDate || curriculumChapter.EndDate > curriculum.EndDate) { curriculum.IsValid = false; } db.SubmitChanges(); // add corresponding curriculum chapter topics var topics = this.GetTopicsByChapterId(curriculumChapter.ChapterRef); foreach (var topic in topics) { var curriculumChapterTopic = new CurriculumChapterTopic { CurriculumChapterRef = curriculumChapter.Id, TopicRef = topic.Id, ThresholdOfSuccess = Constants.DefaultThresholdOfSuccess, BlockTopicAtTesting = false, BlockCurriculumAtTesting = false }; this.AddCurriculumChapterTopic(curriculumChapterTopic); } return curriculumChapter.Id; }
private void attach_CurriculumChapters(CurriculumChapter entity) { this.SendPropertyChanging(); entity.Curriculum = this; }
private void detach_CurriculumChapters(CurriculumChapter entity) { this.SendPropertyChanging(); entity.Chapter = null; }
public int AddCurriculumChapter(CurriculumChapter curriculumChapter) { var db = GetDbContext(); curriculumChapter.IsDeleted = false; db.CurriculumChapters.InsertOnSubmit(curriculumChapter); db.SubmitChanges(); //add corresponding curriculum chapter topics var topics = GetTopicsByChapterId(curriculumChapter.ChapterRef); foreach (var topic in topics) { var curriculumChapterTopic = new CurriculumChapterTopic { CurriculumChapterRef = curriculumChapter.Id, TopicRef = topic.Id, MaxScore = Constants.DefaultTopicMaxScore, BlockTopicAtTesting = false, BlockCurriculumAtTesting = false }; AddCurriculumChapterTopic(curriculumChapterTopic); } return curriculumChapter.Id; }
public void UpdateCurriculumChapter(CurriculumChapter curriculumChapter) { var db = GetDbContext(); var oldCurriculumChapter = GetCurriculumChapter(db, curriculumChapter.Id); oldCurriculumChapter.StartDate = curriculumChapter.StartDate; oldCurriculumChapter.EndDate = curriculumChapter.EndDate; db.SubmitChanges(); }
public void UpdateCurriculumChapter(CurriculumChapter curriculumChapter) { this.storage.UpdateCurriculumChapter(curriculumChapter); this.cacheProvider.Invalidate("curriculumchapter-" + curriculumChapter.Id, "curriculumchapters"); this.cacheProvider.Invalidate("curriculums", "curriculum-" + curriculumChapter.CurriculumRef); }
public int AddChapter(Chapter chapter) { var db = GetDbContext(); chapter.Created = DateTime.Now; chapter.Updated = DateTime.Now; chapter.IsDeleted = false; db.Chapters.InsertOnSubmit(chapter); db.SubmitChanges(); //add corresponding CurriculumChapters var curriculums = GetCurriculumsByDisciplineId(chapter.DisciplineRef); foreach (var curriculum in curriculums) { var curriculumChapter = new CurriculumChapter { ChapterRef = chapter.Id, CurriculumRef = curriculum.Id }; AddCurriculumChapter(curriculumChapter); } return chapter.Id; }
public int AddCurriculumChapter(CurriculumChapter curriculumChapter) { var id = this.storage.AddCurriculumChapter(curriculumChapter); this.cacheProvider.Invalidate("curriculumchapter-" + id, "curriculumchapters"); this.cacheProvider.Invalidate("curriculums", "curriculum-" + curriculumChapter.CurriculumRef); return id; }
public void AddCurriculum() { this.DataPreparer.CreateCurriculumsSet1(); var expectedItems = this.DataPreparer.GetCurriculums(); var controller = this.GetController<CurriculumController>(); // add curriculums expectedItems.ForEach(item => controller.Create(item.ToCreateModel())); // then add "special" curriculum controller.Create( new Curriculum { IsValid = false, IsDeleted = true, DisciplineRef = this.DataPreparer.DisciplineIds[0], UserGroupRef = this.UserService.GetGroup(2).Id }.ToCreateModel()); expectedItems = this.DataPreparer.GetCurriculums(); var allItems = this.CurriculumStorage.GetCurriculums().OrderBy(item => item.Id).ToList(); var actualItems = allItems.Take(expectedItems.Count).ToList(); var actualItem = allItems.Last(); Assert.AreEqual(expectedItems.Count, actualItems.Count); Assert.AreEqual(true, actualItem.IsValid); Assert.AreEqual(false, actualItem.IsDeleted); // add bad curriculum controller = this.GetController<CurriculumController>(); controller.Create( new Curriculum { DisciplineRef = this.DataPreparer.DisciplineIds[1], UserGroupRef = this.UserService.GetGroup(1).Id, StartDate = DateTime.Now.AddDays(1), // bad start date EndDate = DateTime.Now }.ToCreateModel()); Assert.AreEqual(false, controller.ModelState.IsValid); Assert.AreEqual(expectedItems.Count + 1, this.CurriculumStorage.GetCurriculums().Count); // add bad curriculum controller = this.GetController<CurriculumController>(); controller.Create( new Curriculum { DisciplineRef = this.DataPreparer.DisciplineIds[0], // curriculum with same group and discipline already exist! UserGroupRef = this.UserService.GetGroup(2).Id, StartDate = DateTime.Now, EndDate = DateTime.Now }.ToCreateModel()); Assert.AreEqual(false, controller.ModelState.IsValid); Assert.AreEqual(expectedItems.Count + 1, this.CurriculumStorage.GetCurriculums().Count); // add bad curriculum controller = this.GetController<CurriculumController>(); controller.Create( new Curriculum { DisciplineRef = -1, // disciplineId < 0 UserGroupRef = this.UserService.GetGroup(2).Id, StartDate = DateTime.Now, EndDate = DateTime.Now }.ToCreateModel()); Assert.AreEqual(false, controller.ModelState.IsValid); Assert.AreEqual(expectedItems.Count + 1, this.CurriculumStorage.GetCurriculums().Count); // add bad curriculum controller = this.GetController<CurriculumController>(); controller.Create( new Curriculum { DisciplineRef = this.DataPreparer.DisciplineIds[0], UserGroupRef = -1, // groupId < 0 StartDate = DateTime.Now, EndDate = DateTime.Now }.ToCreateModel()); Assert.AreEqual(false, controller.ModelState.IsValid); Assert.AreEqual(expectedItems.Count + 1, this.CurriculumStorage.GetCurriculums().Count); // add bad curriculum controller = this.GetController<CurriculumController>(); controller.Create( new Curriculum { DisciplineRef = this.DataPreparer.DisciplineIds[1], UserGroupRef = this.UserService.GetGroup(1).Id, StartDate = new DateTime(1100, 1, 1), // too small date EndDate = new DateTime(2400, 1, 1) // too big date }.ToCreateModel()); Assert.AreEqual(false, controller.ModelState.IsValid); Assert.AreEqual(expectedItems.Count + 1, this.CurriculumStorage.GetCurriculums().Count); var curriculum = new Curriculum { DisciplineRef = this.DataPreparer.DisciplineIds[0], UserGroupRef = this.UserService.GetGroup(1).Id, StartDate = DateTime.Now, EndDate = DateTime.Now.AddDays(2) }; var curriculumId = this.CurriculumStorage.AddCurriculum(curriculum); var discipline = this.DisciplineStorage.GetDiscipline(this.DataPreparer.DisciplineIds[0]); var chapterId = this.DisciplineStorage.GetChapters(item => item.DisciplineRef == discipline.Id).First().Id; var curriculumChapter = new CurriculumChapter() { ChapterRef = chapterId, CurriculumRef = curriculumId, StartDate = DateTime.Now, EndDate = DateTime.Now.AddDays(4) }; this.CurriculumStorage.AddCurriculumChapter(curriculumChapter); curriculum = this.CurriculumStorage.GetCurriculum(curriculumId); Assert.IsFalse(curriculum.IsValid); }
partial void DeleteCurriculumChapter(CurriculumChapter instance);
partial void UpdateCurriculumChapter(CurriculumChapter instance);
partial void InsertCurriculumChapter(CurriculumChapter instance);