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;
            }
        }
Example #2
0
 private void detach_TopicAssignments(TopicAssignment entity)
 {
     this.SendPropertyChanging();
     entity.Topic = null;
 }
Example #3
0
 private void attach_TopicAssignments(TopicAssignment entity)
 {
     this.SendPropertyChanging();
     entity.Curriculum = this;
 }
        public void UpdateTopicAssignment(TopicAssignment topicAssignment)
        {
            var db = GetDbContext();
            var oldTopicAssignment = GetTopicAssignment(db, topicAssignment.Id);

            oldTopicAssignment.MaxScore = topicAssignment.MaxScore;

            db.SubmitChanges();
        }
        public int AddTopicAssignment(TopicAssignment topicAssignment)
        {
            var db = GetDbContext();
            db.TopicAssignments.InsertOnSubmit(topicAssignment);
            db.SubmitChanges();

            return topicAssignment.Id;
        }
        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;
        }
        /// <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);
            }
        }