Пример #1
0
        public ActionResult Edit(int topicAssignmentId, TopicAssignment topicAssignment)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    topicAssignment.Id = topicAssignmentId;
                    Storage.UpdateTopicAssignment(topicAssignment);

                    return RedirectToRoute("TopicAssignments", new { action = "Index", CurriculumId = Session["CurriculumId"] });
                }
                else
                {
                    return RedirectToAction("Edit");
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #2
0
 private void detach_TopicAssignments(TopicAssignment entity)
 {
     this.SendPropertyChanging();
     entity.Topic = null;
 }
Пример #3
0
 private void attach_TopicAssignments(TopicAssignment entity)
 {
     this.SendPropertyChanging();
     entity.Curriculum = this;
 }
Пример #4
0
        public void UpdateTopicAssignment(TopicAssignment topicAssignment)
        {
            var db = GetDbContext();
            var oldTopicAssignment = GetTopicAssignment(db, topicAssignment.Id);

            oldTopicAssignment.MaxScore = topicAssignment.MaxScore;

            db.SubmitChanges();
        }
Пример #5
0
        public int AddTopicAssignment(TopicAssignment topicAssignment)
        {
            var db = GetDbContext();
            db.TopicAssignments.InsertOnSubmit(topicAssignment);
            db.SubmitChanges();

            return topicAssignment.Id;
        }
Пример #6
0
        public int AddCurriculum(Curriculum curriculum)
        {
            var db = GetDbContext();
            curriculum.IsDeleted = false;
            curriculum.IsValid = true;

            db.Curriculums.InsertOnSubmit(curriculum);
            db.SubmitChanges();

            //add corresponding TopicAssignments
            var topicsInCurrentDiscipline = GetTopicsByDisciplineId(curriculum.DisciplineRef)
                .Where(item => item.TopicTypeRef == (int)Enums.TopicType.Test ||
                    item.TopicTypeRef == (int)Enums.TopicType.TestWithoutCourse);
            foreach (var topic in topicsInCurrentDiscipline)
            {
                TopicAssignment newTopicAssingment = new TopicAssignment()
                {
                    CurriculumRef = curriculum.Id,
                    TopicRef = topic.Id,
                    MaxScore = Constants.DefaultTopicMaxScore
                };

                AddTopicAssignment(newTopicAssingment);
            }

            return curriculum.Id;
        }
Пример #7
0
        /// <summary>
        /// Adds topic assignments for topic.
        /// </summary>
        /// <param name="topic">The topic.</param>
        private void AddTopicAssignments(Topic topic)
        {
            var curriculums = GetDisciplineAssignmnetsByDisciplineId(topic.Chapter.DisciplineRef);
            foreach (Curriculum curriculum in curriculums)
            {
                TopicAssignment newTopicAssignment = new TopicAssignment()
                {
                    CurriculumRef = curriculum.Id,
                    TopicRef = topic.Id,
                    MaxScore = Constants.DefaultTopicMaxScore
                };

                AddTopicAssignment(newTopicAssignment);
            }
        }