Ejemplo n.º 1
0
        public void DeleteCurriculumAssignment(int curriculumAssignmentId)
        {
            var curriculumAssignment = GetCurriculumAssignment(curriculumAssignmentId);

            //delete corresponding CurriculumAssignmentTimelines
            var curriculumAssignmentTimelineIds = GetCurriculumAssignmentTimelines(curriculumAssignmentId).Select(item => item.Id);

            DeleteTimelines(curriculumAssignmentTimelineIds);

            //delete corresponding StageTimelines
            var stageTimelineIds = GetStageTimelinesByCurriculumAssignmentId(curriculumAssignmentId).Select(item => item.Id);

            DeleteTimelines(stageTimelineIds);

            //delete corresponding ThemeAssignments
            var themeAssignmentIds = GetThemeAssignmentsByCurriculumAssignmentId(curriculumAssignmentId).Select(item => item.Id);

            DeleteThemeAssignments(themeAssignmentIds);

            using (var db = new CurriculumManagementDBContext())
            {
                db.CurriculumAssignments.Attach(curriculumAssignment);

                curriculumAssignment.IsDeleted = true;
                db.SaveChanges();
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        public int AddThemeAssignment(ThemeAssignment themeAssignment)
        {
            using (var db = new CurriculumManagementDBContext())
            {
                db.ThemeAssignments.Add(themeAssignment);
                db.SaveChanges();
            }

            return(themeAssignment.Id);
        }
Ejemplo n.º 4
0
        public void UpdateThemeAssignment(ThemeAssignment themeAssignment)
        {
            using (var db = new CurriculumManagementDBContext())
            {
                db.ThemeAssignments.Attach(themeAssignment);

                themeAssignment.MaxScore = themeAssignment.MaxScore;

                db.SaveChanges();
            }
        }
Ejemplo n.º 5
0
        public int AddTimeline(Timeline timeline)
        {
            timeline.IsDeleted = false;

            using (var db = new CurriculumManagementDBContext())
            {
                db.Timelines.Add(timeline);
                db.SaveChanges();
            }

            return(timeline.Id);
        }
Ejemplo n.º 6
0
        public void UpdateTimeline(Timeline timeline)
        {
            using (var db = new CurriculumManagementDBContext())
            {
                db.Timelines.Attach(timeline);

                timeline.StartDate = timeline.StartDate;
                timeline.EndDate   = timeline.EndDate;

                db.SaveChanges();
            }
        }
Ejemplo n.º 7
0
        public void UpdateCurriculumAssignment(CurriculumAssignment curriculumAssignment)
        {
            //var oldCurriculumAssignment = GetCurriculumAssignment(curriculumAssignment.Id);

            using (var db = new CurriculumManagementDBContext())
            {
                db.CurriculumAssignments.Attach(curriculumAssignment);
                curriculumAssignment.UserGroupRef = curriculumAssignment.UserGroupRef;

                db.SaveChanges();
            }
        }
Ejemplo n.º 8
0
        public void DeleteTimeline(int timelineId)
        {
            var timeline = GetTimeline(timelineId);

            using (var db = new CurriculumManagementDBContext())
            {
                db.Timelines.Attach(timeline);

                timeline.IsDeleted = true;

                db.SaveChanges();
            }
        }
Ejemplo n.º 9
0
        public void UpdateCurriculum(Curriculum curriculum)
        {
            var oldCurriculum = GetCurriculum(curriculum.Id);

            using (var db = new CurriculumManagementDBContext())
            {
                db.Curriculums.Attach(oldCurriculum);

                oldCurriculum.Name    = curriculum.Name;
                oldCurriculum.Updated = DateTime.Now;

                db.SaveChanges();
            }
        }
Ejemplo n.º 10
0
        public void UpdateStage(Stage stage)
        {
            Stage oldStage = GetStage(stage.Id);

            using (var db = new CurriculumManagementDBContext())
            {
                db.Stages.Attach(oldStage);

                oldStage.Name    = stage.Name;
                oldStage.Updated = DateTime.Now;

                db.SaveChanges();
            }
        }
Ejemplo n.º 11
0
        public int AddStage(Stage stage)
        {
            using (var db = new CurriculumManagementDBContext())
            {
                stage.Created   = DateTime.Now;
                stage.Updated   = DateTime.Now;
                stage.IsDeleted = false;

                db.Stages.Add(stage);
                db.SaveChanges();

                return(stage.Id);
            }
        }
Ejemplo n.º 12
0
        public int AddCurriculum(Curriculum curriculum)
        {
            using (var db = new CurriculumManagementDBContext())
            {
                curriculum.Created   = DateTime.Now;
                curriculum.Updated   = DateTime.Now;
                curriculum.IsDeleted = false;

                db.Curriculums.Add(curriculum);
                db.SaveChanges();

                return(curriculum.Id);
            }
        }
Ejemplo n.º 13
0
        public void DeleteTimelines(IEnumerable <int> timelineIds)
        {
            var timelines = GetTimelines(timelineIds);

            using (var db = new CurriculumManagementDBContext())
            {
                foreach (Timeline timeline in timelines)
                {
                    db.Timelines.Attach(timeline);
                    timeline.IsDeleted = true;
                }

                db.SaveChanges();
            }
        }
Ejemplo n.º 14
0
        public void DeleteThemeAssignments(IEnumerable <int> ids)
        {
            var themeAssignments = GetThemeAssignments(ids);

            using (var db = new CurriculumManagementDBContext())
            {
                foreach (ThemeAssignment item in themeAssignments)
                {
                    db.ThemeAssignments.Attach(item);
                    item.IsDeleted = true;
                }

                db.SaveChanges();
            }
        }
Ejemplo n.º 15
0
        public void DeleteTheme(int id)
        {
            var theme = GetTheme(id);

            using (var db = new CurriculumManagementDBContext())
            {
                db.Themes.Attach(theme);

                //if it is "Test" then delete corresponding ThemeAssignments.
                if (theme.ThemeType.Id == (int)IUDICO.CurriculumManagement.Models.Enums.ThemeType.Test)
                {
                    DeleteThemeAssignments(theme);
                }

                theme.IsDeleted = true;

                db.SaveChanges();
            }
        }
Ejemplo n.º 16
0
        public void DeleteCurriculum(int id)
        {
            var curriculum = GetCurriculum(id);

            using (var db = new CurriculumManagementDBContext())
            {
                db.Curriculums.Attach(curriculum);

                //delete stages
                var stageIds = GetStages(id).Select(item => item.Id);
                DeleteStages(stageIds);

                //delete corresponding CurriculumAssignments
                var curriculumAssignmentIds = GetCurriculumAssignmnetsByCurriculumId(id).Select(item => item.Id);
                DeleteCurriculumAssignments(curriculumAssignmentIds);

                curriculum.IsDeleted = true;
                db.SaveChanges();
            }
        }
Ejemplo n.º 17
0
        public void UpdateTheme(Theme theme)
        {
            var oldTheme = GetTheme(theme.Id);

            using (var db = new CurriculumManagementDBContext())
            {
                /*try
                 * {*/
                db.Themes.Attach(oldTheme);

                oldTheme.Name      = theme.Name;
                oldTheme.SortOrder = theme.SortOrder;
                oldTheme.CourseRef = theme.CourseRef;
                oldTheme.Updated   = DateTime.Now;

                //if ThemeType has changed then add or remove corresponding ThemeAssignments.
                if (oldTheme.ThemeTypeRef != theme.ThemeTypeRef)
                {
                    oldTheme.ThemeTypeRef = theme.ThemeTypeRef;
                    if (theme.ThemeType.Id == (int)IUDICO.CurriculumManagement.Models.Enums.ThemeType.Test)
                    {
                        AddThemeAssignments(theme);
                    }
                    else
                    {
                        DeleteThemeAssignments(theme);
                    }
                }

                db.SaveChanges();

                /*}
                 * catch (ChangeConflictException)
                 * {
                 *  foreach (ObjectChangeConflict conflict in db.ChangeConflicts)
                 *  {
                 *      conflict.Resolve(RefreshMode.KeepChanges);
                 *  }
                 * }*/
            }
        }
Ejemplo n.º 18
0
        public Theme ThemeDown(int themeId)
        {
            var           theme  = GetTheme(themeId);
            IList <Theme> themes = GetThemesByStageId(theme.StageRef).ToList();

            using (var db = new CurriculumManagementDBContext())
            {
                int index = themes.IndexOf(theme);
                if (index != -1 && index != themes.Count - 1)
                {
                    db.Themes.Attach(themes[index - 1]);

                    int temp = themes[index + 1].SortOrder;
                    themes[index + 1].SortOrder = theme.SortOrder;
                    theme.SortOrder             = temp;
                }

                db.SaveChanges();
            }

            return(theme);
        }
Ejemplo n.º 19
0
        public void DeleteStage(int id)
        {
            var stage = GetStage(id);

            using (var db = new CurriculumManagementDBContext())
            {
                db.Stages.Attach(stage);

                //delete themes
                var themeIds = GetThemesByStageId(id).Select(item => item.Id);
                DeleteThemes(themeIds);

                //delete corresponding StageTimelines
                var stageTimelines = GetStageTimelinesByStageId(id);
                foreach (Timeline timeline in stageTimelines)
                {
                    DeleteTimeline(timeline.Id);
                }

                stage.IsDeleted = true;
                db.SaveChanges();
            }
        }
Ejemplo n.º 20
0
        public int AddTheme(Theme theme)
        {
            using (var db = new CurriculumManagementDBContext())
            {
                theme.Created   = DateTime.Now;
                theme.Updated   = DateTime.Now;
                theme.IsDeleted = false;

                db.Themes.Add(theme);
                db.SaveChanges();

                theme.SortOrder = theme.Id;
                UpdateTheme(theme);
            }

            //if it is "Test" then add corresponding ThemeAssignments.
            if (theme.ThemeType.Id == (int)IUDICO.CurriculumManagement.Models.Enums.ThemeType.Test)
            {
                AddThemeAssignments(theme);
            }

            return(theme.Id);
        }