예제 #1
0
        private void DeleteSemesterDiscipline(EducationPlan educationPlan, SemesterDiscipline semesterDiscipline)
        {
            if (IsSelectedSemesterDiscipline(semesterDiscipline))
            {
                EducationProcessContext         context = new EducationProcessContext();
                EducationPlanSemesterDiscipline educationPlanSemesterDiscipline =
                    context.EducationPlanSemesterDisciplines
                    .First(x => x.EducationPlanId == educationPlan.EducationPlanId &&
                           x.SemesterDisciplineId == semesterDiscipline.SemesterDisciplineId);

                context.EducationPlanSemesterDisciplines.Remove(educationPlanSemesterDiscipline);

                EducationPlanSemesterDiscipline?otherEducationPlanSemesterDiscipline =
                    context.EducationPlanSemesterDisciplines
                    .FirstOrDefault(x => x.SemesterDisciplineId == semesterDiscipline.SemesterDisciplineId &&
                                    x.EducationPlanId != educationPlan.EducationPlanId);

                if (otherEducationPlanSemesterDiscipline == null)
                {
                    context.EducationPlans.Remove(educationPlan);
                }

                context.SaveChanges();
                RefreshSemesterDisciplines(educationPlan);
            }
        }
예제 #2
0
        private void AddNewSemesterDiscipline(EducationPlan educationPlan, SemesterDiscipline semesterDiscipline)
        {
            EducationProcessContext context = new EducationProcessContext();

            context.SemesterDisciplines.Add(semesterDiscipline);
            context.SaveChanges();
            EducationPlanSemesterDiscipline educationPlanSemesterDiscipline = new EducationPlanSemesterDiscipline()
            {
                EducationPlanId      = educationPlan.EducationPlanId,
                SemesterDisciplineId = semesterDiscipline.SemesterDisciplineId
            };

            context.EducationPlanSemesterDisciplines.Add(educationPlanSemesterDiscipline);
            context.SaveChanges();
        }
예제 #3
0
        private void CopySemesterDisciplines(EducationPlan educationPlan, EducationPlan copyingEducationPlan)
        {
            EducationProcessContext context = new EducationProcessContext();

            EducationPlanSemesterDiscipline[] copyingSemesterDisciplines = context.EducationPlanSemesterDisciplines
                                                                           .Where(x => x.EducationPlanId == copyingEducationPlan.EducationPlanId)
                                                                           .AsNoTracking()
                                                                           .ToArray();
            foreach (var copyingSemesterDiscipline in copyingSemesterDisciplines)
            {
                EducationPlanSemesterDiscipline educationPlanSemesterDiscipline =
                    new EducationPlanSemesterDiscipline()
                {
                    EducationPlanId      = educationPlan.EducationPlanId,
                    SemesterDisciplineId = copyingSemesterDiscipline.SemesterDisciplineId
                };
                context.EducationPlanSemesterDisciplines.Add(educationPlanSemesterDiscipline);
            }
            context.SaveChanges();
        }