コード例 #1
0
        public int AddCurriculumAssignment(CurriculumAssignment curriculumAssignment)
        {
            curriculumAssignment.IsDeleted = false;
            curriculumAssignment.IsValid   = true;

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

            //add corresponding ThemeAssignments
            var themesInCurrentCurriculum = GetThemesByCurriculumId(curriculumAssignment.CurriculumRef)
                                            .Where(item => item.ThemeTypeRef == (int)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);
        }
コード例 #2
0
        public int AddCurriculumAssignment(CurriculumAssignment curriculumAssignment)
        {
            using (var db = new CurriculumManagementDBContext())
            {
                curriculumAssignment.IsDeleted = false;

                db.CurriculumAssignments.Add(curriculumAssignment);
                db.SaveChanges();
            }

            //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);
        }
コード例 #3
0
        public int AddThemeAssignment(ThemeAssignment themeAssignment)
        {
            _Db.ThemeAssignments.InsertOnSubmit(themeAssignment);
            _Db.SubmitChanges();

            return(themeAssignment.Id);
        }
コード例 #4
0
        public void UpdateThemeAssignment(ThemeAssignment themeAssignment)
        {
            var oldThemeAssignment = GetThemeAssignment(themeAssignment.Id);

            oldThemeAssignment.MaxScore = themeAssignment.MaxScore;

            _Db.SubmitChanges();
        }
コード例 #5
0
 public static void AreEqual(ThemeAssignment actual, ThemeAssignment expected)
 {
     Assert.AreEqual(expected.ThemeRef, actual.ThemeRef);
     Assert.AreEqual(expected.Id, actual.Id);
     Assert.AreEqual(expected.IsDeleted, actual.IsDeleted);
     Assert.AreEqual(expected.CurriculumAssignmentRef, actual.CurriculumAssignmentRef);
     Assert.AreEqual(expected.MaxScore, actual.MaxScore);
 }
コード例 #6
0
        public void UpdateThemeAssignment(ThemeAssignment themeAssignment)
        {
            var db = GetDbContext();
            var oldThemeAssignment = GetThemeAssignment(db, themeAssignment.Id);

            oldThemeAssignment.MaxScore = themeAssignment.MaxScore;

            db.SubmitChanges();
        }
コード例 #7
0
        public int AddThemeAssignment(ThemeAssignment themeAssignment)
        {
            var db = GetDbContext();

            db.ThemeAssignments.InsertOnSubmit(themeAssignment);
            db.SubmitChanges();

            return(themeAssignment.Id);
        }
コード例 #8
0
        public int AddThemeAssignment(ThemeAssignment themeAssignment)
        {
            using (var db = new CurriculumManagementDBContext())
            {
                db.ThemeAssignments.Add(themeAssignment);
                db.SaveChanges();
            }

            return(themeAssignment.Id);
        }
コード例 #9
0
        public void UpdateThemeAssignment(ThemeAssignment themeAssignment)
        {
            using (var db = new CurriculumManagementDBContext())
            {
                db.ThemeAssignments.Attach(themeAssignment);

                themeAssignment.MaxScore = themeAssignment.MaxScore;

                db.SaveChanges();
            }
        }
コード例 #10
0
        /// <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);
            }
        }
コード例 #11
0
        public static void AreEqual(IList <ThemeAssignment> expected, IList <ThemeAssignment> actual)
        {
            Assert.AreEqual(expected.Count, actual.Count);

            foreach (ThemeAssignment expectedItem in expected)
            {
                ThemeAssignment actualItem = actual.SingleOrDefault(item => item.Id == expectedItem.Id);
                if (actualItem != null)
                {
                    AreEqual(expectedItem, actualItem);
                }
                else
                {
                    Assert.Fail(String.Format("Item with id={0} doesn't exist in actual collection, but expected in expected collection",
                                              expectedItem.Id));
                }
            }
        }
コード例 #12
0
        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;
            }
        }
コード例 #13
0
        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;
            }
        }
コード例 #14
0
        public ActionResult Edit(int themeAssignmentId)
        {
            try
            {
                ThemeAssignment      themeAssignment      = Storage.GetThemeAssignment(themeAssignmentId);
                CurriculumAssignment curriculumAssignment = Storage.GetCurriculumAssignment(themeAssignment.CurriculumAssignmentRef);
                Curriculum           curriculum           = Storage.GetCurriculum(curriculumAssignment.CurriculumRef);
                Theme theme = Storage.GetTheme(themeAssignment.ThemeRef);
                Group group = Storage.GetGroup(curriculumAssignment.UserGroupRef);

                Session["CurriculumAssignmentId"] = themeAssignment.CurriculumAssignmentRef;
                ViewData["GroupName"]             = group.Name;
                ViewData["CurriculumName"]        = curriculum.Name;
                ViewData["StageName"]             = theme.Name;
                return(View(themeAssignment));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #15
0
        public int AddCurriculumAssignment(CurriculumAssignment curriculumAssignment)
        {
            var db = GetDbContext();
            curriculumAssignment.IsDeleted = false;
            curriculumAssignment.IsValid = true;

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

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

                AddThemeAssignment(newThemeAssingment);
            }

            return curriculumAssignment.Id;
        }
コード例 #16
0
        public int AddThemeAssignment(ThemeAssignment themeAssignment)
        {
            _Db.ThemeAssignments.InsertOnSubmit(themeAssignment);
            _Db.SubmitChanges();

            return themeAssignment.Id;
        }
コード例 #17
0
        public void UpdateThemeAssignment(ThemeAssignment themeAssignment)
        {
            var oldThemeAssignment = GetThemeAssignment(themeAssignment.Id);

            oldThemeAssignment.MaxScore = themeAssignment.MaxScore;

            _Db.SubmitChanges();
        }
コード例 #18
0
        /// <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);
            }
        }
コード例 #19
0
        public int AddThemeAssignment(ThemeAssignment themeAssignment)
        {
            var db = GetDbContext();
            db.ThemeAssignments.InsertOnSubmit(themeAssignment);
            db.SubmitChanges();

            return themeAssignment.Id;
        }
コード例 #20
0
        public void UpdateThemeAssignment(ThemeAssignment themeAssignment)
        {
            var db = GetDbContext();
            var oldThemeAssignment = GetThemeAssignment(db, themeAssignment.Id);

            oldThemeAssignment.MaxScore = themeAssignment.MaxScore;

            db.SubmitChanges();
        }