public ActionResult Edit(int themeAssignmentId, ThemeAssignment themeAssignment)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    themeAssignment.Id = themeAssignmentId;
                    Storage.UpdateThemeAssignment(themeAssignment);

                    return RedirectToRoute("ThemeAssignments", new { action = "Index", CurriculumAssignmentId = Session["CurriculumAssignmentId"] });
                }
                else
                {
                    return RedirectToAction("Edit");
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public int AddCurriculumAssignment(CurriculumAssignment curriculumAssignment)
        {
            curriculumAssignment.IsDeleted = false;

            _Db.CurriculumAssignments.InsertOnSubmit(curriculumAssignment);
            _Db.SubmitChanges();

            //add corresponding ThemeAssignments
            var themesInCurrentCurriculum = GetThemesByCurriculumId(curriculumAssignment.CurriculumRef)
                .Where(item => item.ThemeTypeRef == (int)IUDICO.CurriculumManagement.Models.Enums.ThemeType.Test);
            foreach (var theme in themesInCurrentCurriculum)
            {
                ThemeAssignment newThemeAssingment = new ThemeAssignment()
                {
                    CurriculumAssignmentRef = curriculumAssignment.Id,
                    ThemeRef = theme.Id,
                    MaxScore = Constants.DefaultThemeMaxScore
                };

                AddThemeAssignment(newThemeAssingment);
            }

            return curriculumAssignment.Id;
        }
Example #3
0
        public void UpdateThemeAssignmentTest()
        {
            //Test UpdateThemeAssignment() with null
            try
            {
                storage.UpdateThemeAssignment(null);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.AreEqual(true, true);
            }

            //Test UpdateThemeAssignment()
            ICourseService courseService = lmsService.FindService<ICourseService>();
            IUserService userService = lmsService.FindService<IUserService>();
            List<Group> groups = userService.GetGroups().ToList();
            List<Course> courses = courseService.GetCourses().ToList();
            int curriculumId = storage.AddCurriculum(Utils.GetDefaultCurriculum());
            int stageId = storage.AddStage(Utils.GetDefaultStage(curriculumId));
            int themeId = storage.AddTheme(new Theme() { Name = "Theme", CourseRef = courses[0].Id, StageRef = stageId, ThemeTypeRef = 1 });
            int curriculumAssignmentId = storage.AddCurriculumAssignment(Utils.GetDefaultCurriculumAssignment(curriculumId, groups[0].Id));

            ThemeAssignment themeAssignment = new ThemeAssignment() { ThemeRef = themeId, MaxScore = 100, IsDeleted = false, CurriculumAssignmentRef = curriculumAssignmentId };
            int themeAssignmentId = storage.AddThemeAssignment(themeAssignment);
            AdvAssert.AreEqual(themeAssignment, storage.GetThemeAssignment(themeAssignmentId));

            themeAssignment.MaxScore = 1;
            storage.UpdateThemeAssignment(themeAssignment);

            AdvAssert.AreEqual(themeAssignment, storage.GetThemeAssignment(themeAssignmentId));

            //Secondary update
            themeAssignment.MaxScore = 50;
            Assert.AreNotEqual(themeAssignment.MaxScore, storage.GetThemeAssignment(themeAssignmentId).MaxScore);
        }
        /// <summary>
        /// Adds theme assignments for theme.
        /// </summary>
        /// <param name="theme">The theme.</param>
        private void AddThemeAssignments(Theme theme)
        {
            var curriculumAssignments = GetCurriculumAssignmnetsByCurriculumId(theme.Stage.CurriculumRef);
            foreach (CurriculumAssignment curriculumAssignment in curriculumAssignments)
            {
                ThemeAssignment newThemeAssignment = new ThemeAssignment()
                {
                    CurriculumAssignmentRef = curriculumAssignment.Id,
                    ThemeRef = theme.Id,
                    MaxScore = Constants.DefaultThemeMaxScore
                };

                AddThemeAssignment(newThemeAssignment);
            }
        }
        public void UpdateThemeAssignment(ThemeAssignment themeAssignment)
        {
            var oldThemeAssignment = GetThemeAssignment(themeAssignment.Id);

            oldThemeAssignment.MaxScore = themeAssignment.MaxScore;

            _Db.SubmitChanges();
        }
        public int AddThemeAssignment(ThemeAssignment themeAssignment)
        {
            _Db.ThemeAssignments.InsertOnSubmit(themeAssignment);
            _Db.SubmitChanges();

            return themeAssignment.Id;
        }
        public int AddThemeAssignment(ThemeAssignment themeAssignment)
        {
            using (var db = new CurriculumManagementDBContext())
            {
                db.ThemeAssignments.Add(themeAssignment);
                db.SaveChanges();
            }

            return themeAssignment.Id;
        }
        public void UpdateThemeAssignment(ThemeAssignment themeAssignment)
        {
            using (var db = new CurriculumManagementDBContext())
            {
                db.ThemeAssignments.Attach(themeAssignment);
                
                themeAssignment.MaxScore = themeAssignment.MaxScore;

                db.SaveChanges();
            }
        }
		private void detach_ThemeAssignments(ThemeAssignment entity)
		{
			this.SendPropertyChanging();
			entity.CurriculumAssignment = null;
		}
Example #10
0
 partial void DeleteThemeAssignment(ThemeAssignment instance);
Example #11
0
 partial void UpdateThemeAssignment(ThemeAssignment instance);
Example #12
0
 partial void InsertThemeAssignment(ThemeAssignment instance);
Example #13
0
		private void attach_ThemeAssignments(ThemeAssignment entity)
		{
			this.SendPropertyChanging();
			entity.Theme = this;
		}