示例#1
0
        private void ShowSemesterDisciplineEditor(EducationPlan educationPlan, SemesterDiscipline semesterDiscipline)
        {
            SemesterDisciplineEditViewModel viewModel = new SemesterDisciplineEditViewModel(educationPlan, semesterDiscipline);

            new SemesterDisciplineEditorWindow(viewModel).ShowDialog();
            RefreshSemesterDisciplines(educationPlan);
        }
示例#2
0
 public EducationPlanImporterViewModel()
 {
     AddingObectsPermission   = true;
     OpenPlanEditorPermission = true;
     Plan = new EducationPlan();
     Session.Data.EducationPlans.Add(Plan);
 }
示例#3
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);
            }
        }
示例#4
0
        public long Update(EducationPlan educationPlan)
        {
            if (educationPlan == null)
            {
                _logger.Error("ArgumentNullException educationPlan");
                throw new ArgumentNullException("educationPlan");
            }

            _logger.Debug(string.Format(_culture, "Update education plan with name employee {0}", educationPlan.NameEmployee));

            var           educationPlans        = GetAllEducationPlans();
            EducationPlan educationPlanToUpdate = educationPlans.FirstOrDefault(ep => ep.Id == educationPlan.Id);

            if (educationPlanToUpdate == null)
            {
                string errorMessage = string.Format(_culture, "No education plan found with id {0}", educationPlan.Id);
                _logger.Error("ArgumentException: " + errorMessage);
                throw new ArgumentException(errorMessage);
            }

            int index = educationPlans.IndexOf(educationPlanToUpdate);

            educationPlans[index] = educationPlan;

            SaveNewUpdatedEducationPlan(educationPlanToUpdate);
            WriteEducationPlansToFile(educationPlans);

            _logger.Debug(string.Format(_culture, "Education plan updated with name employee {0} and generated id {1}", educationPlan.NameEmployee, educationPlan.Id));

            return(educationPlan.Id);
        }
        private void ShowEducationPlanEditor(EducationPlan educationPlan)
        {
            EducationPlanEditViewModel viewModel = new EducationPlanEditViewModel(educationPlan);

            new EducationPlanEditorWindow(viewModel).ShowDialog();
            RefreshEducationPlans();
        }
示例#6
0
        public string GenerateWord(EducationPlan educationPlan)
        {
            _logger.Debug("GenerateWord");

            if (!Directory.Exists(_path))
            {
                _logger.Debug(string.Format(_culture, "Path {0} for word files doesn't exists", _path));
                Directory.CreateDirectory(_path);
            }

            string fileName = @"\Opleidingsplan-" + educationPlan.NameEmployee + "-" + educationPlan.Created.ToString(_dateFromat) + ".docx";

            _document = DocX.Create(_path + fileName);

            _educationPlan = educationPlan;
            GenerateHeader();
            InsertNewLine();
            InsertEducationPlanTable(_educationPlan.PlannedCourses.ToList(), true);
            InsertNewLine();
            _document.InsertParagraph("Op termijn te volgen").Bold().UnderlineStyle(UnderlineStyle.singleLine).FontSize(_fontSizeTable).Font(_fontFamily);
            InsertNewLine();
            InsertEducationPlanTable(_educationPlan.NotPlannedCourses.ToList(), false);
            InsertFooter();

            _document.Save();

            return(fileName);
        }
示例#7
0
        public ActionResult DeleteConfirmed(int id)
        {
            EducationPlan educationPlan = db.EducationPlans.Find(id);

            db.EducationPlans.Remove(educationPlan);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#8
0
 private void EditSemesterDiscipline(EducationPlan educationPlan, SemesterDiscipline semesterDiscipline)
 {
     if (IsSelectedSemesterDiscipline(semesterDiscipline))
     {
         ShowSemesterDisciplineEditor(educationPlan, semesterDiscipline);
         RefreshSemesterDisciplines(educationPlan);
     }
 }
 private void EditEducationPlan(EducationPlan educationPlan)
 {
     if (IsSelectedEducationPlan(educationPlan))
     {
         ShowEducationPlanEditor(educationPlan);
         RefreshEducationPlans();
     }
 }
        public EducationPlan GenerateEducationPlan(RestEducationPlan educationPlan, EducationPlan oldEducationplan)
        {
            System.Diagnostics.Debug.WriteLine("parameters " + new JavaScriptSerializer().Serialize(educationPlan) + ", old: " + new JavaScriptSerializer().Serialize(educationPlan));
            if (educationPlan == null)
            {
                _logger.Error("ArgumentNullException: educationPlan");
                throw new ArgumentNullException("educationPlan");
            }

            _logger.Debug(string.Format(_culture, "GenerateEducationPlan for employee {0}", educationPlan.NameEmployee));

            _planner.StartDate    = educationPlan.InPaymentFrom;
            _planner.EndDate      = educationPlan.EmployableFrom;
            _planner.BlockedDates = educationPlan.BlockedDates;

            var           educationplanData = Mapper.Map <EducationPlanData>(educationPlan);
            CourseProfile profile           = null;

            if (educationPlan.ProfileId != 0)
            {
                _logger.Debug(string.Format(_culture, "ProfileId exists: {0}", educationPlan.ProfileId));
                profile = _profileDataMapper.FindById(educationPlan.ProfileId);
                educationplanData.Profile   = profile.Name;
                educationplanData.ProfileId = educationPlan.ProfileId;
            }

            var educationPlanCourses = educationPlan.Courses.Where(course => !course.Code.StartsWith("OLC"));

            _logger.Debug("Find courses from service");
            IEnumerable <Integration.Course>             courses       = _courseService.FindCourses(educationPlanCourses.Select(course => course.Code));
            List <OpleidingsplanGenerator.Models.Course> coursesToPlan = ConvertCourses(courses, profile, educationPlan.Courses);

            List <OpleidingsplanGenerator.Models.PinnedCourseImplementation> implementationConstraints = new List <OpleidingsplanGenerator.Models.PinnedCourseImplementation>();

            if (educationPlan.ImplementationConstraints != null)
            {
                implementationConstraints = ConvertImplementationConstraints(educationPlan.ImplementationConstraints);
            }

            if (oldEducationplan == null)
            {
                _planner.PlanCoursesWithOlc(coursesToPlan, implementationConstraints);
            }
            else
            {
                _planner.PlanCoursesWithOlcInOldEducationPlan(coursesToPlan, oldEducationplan, implementationConstraints);
            }

            _planner.AddModules(_moduleDataMapper.FindAll());

            OverrideRestCourse(_planner, educationPlan.Courses);

            var output = _educationPlanOutputter.GenerateEducationPlan(educationplanData);

            System.Diagnostics.Debug.WriteLine("parameters " + new JavaScriptSerializer().Serialize(output));

            return(output);
        }
 private bool IsSelectedEducationPlan(EducationPlan educationPlan)
 {
     if (educationPlan == null)
     {
         _dialogCoordinator.ShowMessageAsync(this, "Внимание", "Выберите учебный план");
         return(false);
     }
     return(true);
 }
 public Group[] GetRelevantGroupsByEducationPlan(EducationPlan educationPlan)
 {
     Group[] groups = _context.Groups
                      .Where(x => x.ReceivedEducation.ReceivedSpecialty.SpecialtieId == educationPlan.SpecialtieId &&
                             x.EducationPlanId == null)
                      .Include(x => x.ReceivedEducation)
                      .ThenInclude(x => x.ReceivedSpecialty)
                      .ToArray();
     return(groups);
 }
        public AddGroupToEducationPlanViewModel(EducationPlan educationPlan)
        {
            _dialogCoordinator = DialogCoordinator.Instance;
            _educationPlan     = educationPlan;
            _context           = new EducationProcessContext();

            Groups            = new ObservableCollection <Group>(GetRelevantGroupsByEducationPlan(educationPlan));
            ChainGroupCommand = new RelayCommand(null, _ => ChainGroup(SelectedGroup));
            CancelCommand     = new RelayCommand(null, o => ((MetroWindow)o).Close());
        }
        public EducationPlan PreviewEducationPlan(RestEducationPlan educationPlan)
        {
            EducationPlan oldEducationplan = null;

            if (educationPlan.EducationPlanId != 0)
            {
                oldEducationplan = _educationPlanDataMapper.FindById(educationPlan.EducationPlanId);
            }

            return(GenerateEducationPlan(educationPlan, oldEducationplan));
        }
示例#15
0
        private void SaveSemesterDiscipline(EducationPlan educationPlan, SemesterDiscipline semesterDiscipline)
        {
            if (SelectedDiscipline == null)
            {
                ShowDialog("Ошиюка", "Выберите дисциплину");
                return;
            }

            if (SelectedSemester == null)
            {
                ShowDialog("Ошиюка", "Выберите семестр");
                return;
            }

            if (IsThereDisciplineOnSemester(_educationPlan, semesterDiscipline))
            {
                ShowDialog("Ошибка", "На данный семестр уже имеется такая дисциплина");
                return;
            }

            bool isNewSemesterDiscipline = semesterDiscipline == null;

            if (isNewSemesterDiscipline)
            {
                semesterDiscipline = new SemesterDiscipline();
            }
            else
            {
                semesterDiscipline.SemesterId = SelectedSemester.SemesterId;
            }

            semesterDiscipline.DisciplineId             = SelectedDiscipline.DisciplineId;
            semesterDiscipline.CertificationFormId      = SelectedCertificationForm?.CertificationFormId;
            semesterDiscipline.TheoryLessonHours        = TheoryLessonHours;
            semesterDiscipline.PracticeWorkHours        = PracticeWorkHours;
            semesterDiscipline.LaboratoryWorkHours      = LaboratoryWorkHours;
            semesterDiscipline.ControlWorkHours         = ControlWorkHours;
            semesterDiscipline.IndependentWorkHours     = IndependentWorkHours;
            semesterDiscipline.ConsultationHours        = ConsultationHours;
            semesterDiscipline.ExamHours                = ExamHours;
            semesterDiscipline.EducationalPracticeHours = EducationalPracticeHours;
            semesterDiscipline.ProductionPracticeHours  = ProductionPracticeHours;

            if (isNewSemesterDiscipline)
            {
                AddNewSemesterDiscipline(educationPlan, semesterDiscipline);
            }
            else
            {
                UpdateSemesterDiscipline(educationPlan, semesterDiscipline);
            }

            _context.SaveChanges();
        }
        public void EducationPlan_CalculatedProperties_NotPlannedCourses()
        {
            // Arrange
            EducationPlan educationPlan = GetDummyEducationPlanWithNotPlannedCourses();

            // Assert
            Assert.AreEqual(0, educationPlan.PlannedCoursesTotalPrice);
            Assert.AreEqual(0, educationPlan.PlannedCoursesTotalPriceWithDiscount);
            Assert.AreEqual(2200, educationPlan.NotPlannedCoursesTotalPrice);
            Assert.AreEqual(1760, educationPlan.NotPlannedCoursesTotalPriceWithDiscount);
        }
示例#17
0
 public ActionResult Edit([Bind(Include = "Id,IdSpecialty,IdDiscipline,TotalTime,DateInstall")] EducationPlan educationPlan)
 {
     if (ModelState.IsValid)
     {
         db.Entry(educationPlan).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdDiscipline = new SelectList(db.Disciplines, "Id", "Title", educationPlan.IdDiscipline);
     ViewBag.IdSpecialty  = new SelectList(db.Specialties, "Id", "Title", educationPlan.IdSpecialty);
     return(View(educationPlan));
 }
示例#18
0
 private void RefreshSemesterDisciplines(EducationPlan educationPlan)
 {
     SemesterDiscipline[] semesterDisciplines = new EducationProcessContext()
                                                .EducationPlanSemesterDisciplines
                                                .Where(x => x.EducationPlanId == educationPlan.EducationPlanId)
                                                .Include(x => x.SemesterDiscipline)
                                                .ThenInclude(x => x.Discipline)
                                                .Include(x => x.SemesterDiscipline)
                                                .ThenInclude(x => x.Semester)
                                                .Select(x => x.SemesterDiscipline)
                                                .ToArray();
     SemesterDisciplines = new ObservableCollection <SemesterDiscipline>(semesterDisciplines);
 }
示例#19
0
        private void SaveNewUpdatedEducationPlan(EducationPlan educationPlan)
        {
            if (!Directory.Exists(_updatedDirPath))
            {
                _logger.Debug(string.Format(_culture, "Save new updated education plan. Directory does not exists with path {0}", _updatedDirPath));
                Directory.CreateDirectory(_updatedDirPath);
            }

            var convertedJson = JsonConvert.SerializeObject(educationPlan, Formatting.Indented);

            File.WriteAllText(Path.Combine(_updatedDirPath, educationPlan.Id + ".json"), convertedJson);
            _logger.Debug(string.Format(_culture, "Saved new updated education plan to directory {0} with id {1} and employee {2}", _updatedDirPath, educationPlan.Id, educationPlan.NameEmployee));
        }
        public void Update_WithNotExistingEducationPlan_ExceptionThrowed()
        {
            // Arrange
            IEducationPlanDataMapper dataMapper    = new EducationPlanJsonDataMapper(_educationPlanPath, _updatedDirPath);
            EducationPlan            educationPlan = GetDummyEducationPlan();

            educationPlan.Id = 100;

            // Act
            dataMapper.Update(educationPlan);

            // Assert ArgumentException
        }
示例#21
0
        // GET: EducationPlans/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EducationPlan educationPlan = db.EducationPlans.Find(id);

            if (educationPlan == null)
            {
                return(HttpNotFound());
            }
            return(View(educationPlan));
        }
示例#22
0
        private bool IsThereDisciplineOnSemester(EducationPlan educationPlan, SemesterDiscipline semesterDiscipline)
        {
            int semesterDisciplineId = semesterDiscipline != null ? semesterDiscipline.SemesterDisciplineId : 0;

            if (_context.EducationPlanSemesterDisciplines
                .FirstOrDefault(x => x.SemesterDiscipline.Semester.Number == SelectedSemester.Number &&
                                x.EducationPlanId == educationPlan.EducationPlanId &&
                                x.SemesterDiscipline.DisciplineId == SelectedDiscipline.DisciplineId &&
                                x.SemesterDisciplineId != semesterDisciplineId) != null)
            {
                return(true);
            }
            return(false);
        }
        public EducationPlanGroupsMenuViewModel(INavigationManager navigationManager, EducationPlan educationPlan)
        {
            _navigationManager = navigationManager;
            _educationPlan     = educationPlan;
            _dialogCoordinator = DialogCoordinator.Instance;
            _context           = new EducationProcessContext();

            PageBackCommand     = new RelayCommand(null, _ => _navigationManager.Back());
            ChainGroupCommand   = new RelayCommand(null, _ => ChainGroup());
            UnchainGroupCommand = new RelayCommand(null, _ => UnchainGroup(SelectedGroup));

            Group[] groups = GetGroupsByEducationPlanId(educationPlan.EducationPlanId);
            Groups = new ObservableCollection <Group>(groups);
        }
示例#24
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();
        }
        public void Insert_EducationPlanInserted()
        {
            // Arrange
            IEducationPlanDataMapper dataMapper    = new EducationPlanJsonDataMapper(_educationPlanPath, _updatedDirPath);
            EducationPlan            educationPlan = GetDummyEducationPlan();

            // Act
            var result = dataMapper.Insert(educationPlan);

            // Assert
            var educationPlans = dataMapper.Find(ep => ep.NameEmployee == "Pim Verheij");

            Assert.AreEqual(1, educationPlans.Count());
            Assert.AreEqual(4, result);
        }
        public void Update_CheckNewUpdateFileWithOldData()
        {
            // Arrange
            IEducationPlanDataMapper dataMapper    = new EducationPlanJsonDataMapper(_educationPlanPath, _updatedDirPath);
            EducationPlan            educationPlan = GetDummyEducationPlan();

            educationPlan.Id = 1;

            // Act
            var result = dataMapper.Update(educationPlan);

            // Assert
            Assert.AreEqual(1, result);
            Assert.IsTrue(File.Exists("../../Data/Updated/1.json"));
        }
示例#27
0
        private void UpdateSemesterDiscipline(EducationPlan educationPlan, SemesterDiscipline semesterDiscipline)
        {
            EducationProcessContext context   = new EducationProcessContext();
            bool isChainedForOtherDisciplines =
                context.EducationPlanSemesterDisciplines.FirstOrDefault(x =>
                                                                        x.EducationPlanId != educationPlan.EducationPlanId &&
                                                                        x.SemesterDisciplineId == semesterDiscipline.SemesterDisciplineId) != null;

            if (isChainedForOtherDisciplines)
            {
                AddNewSemesterDiscipline(educationPlan, semesterDiscipline);
                return;
            }
            context.SemesterDisciplines.Update(semesterDiscipline);
            context.SaveChanges();
        }
示例#28
0
        // GET: EducationPlans/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EducationPlan educationPlan = db.EducationPlans.Find(id);

            if (educationPlan == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IdDiscipline = new SelectList(db.Disciplines, "Id", "Title", educationPlan.IdDiscipline);
            ViewBag.IdSpecialty  = new SelectList(db.Specialties, "Id", "Title", educationPlan.IdSpecialty);
            return(View(educationPlan));
        }
示例#29
0
        private void SaveEducationPlan(EducationPlan educationPlan)
        {
            if (SelectedAcademicYear == null)
            {
                _dialogCoordinator.ShowMessageAsync(this, null, "Выберите учебный год");
                return;
            }
            if (SelectedSpecialty == null)
            {
                _dialogCoordinator.ShowMessageAsync(this, null, "Выберите специальность");
                return;
            }

            if (string.IsNullOrWhiteSpace(EducationPlanName))
            {
                _dialogCoordinator.ShowMessageAsync(this, null, "Назовите учебный план");
                return;
            }

            EducationProcessContext context = new EducationProcessContext();

            if (educationPlan == null)
            {
                educationPlan = new EducationPlan()
                {
                    Name           = EducationPlanName,
                    AcademicYearId = SelectedAcademicYear.AcademicYearId,
                    SpecialtieId   = SelectedSpecialty.SpecialtieId
                };
                context.EducationPlans.Add(educationPlan);
            }
            else
            {
                educationPlan.Name           = EducationPlanName;
                educationPlan.AcademicYearId = SelectedAcademicYear.AcademicYearId;
                educationPlan.SpecialtieId   = SelectedSpecialty.SpecialtieId;
                context.EducationPlans.Update(educationPlan);
            }
            context.SaveChanges();

            if (SelectedEducationPlan != null)
            {
                CopySemesterDisciplines(educationPlan, SelectedEducationPlan);
            }

            _dialogCoordinator.ShowMessageAsync(this, "Сохранено", null);
        }
        public void Update_CheckNewUpdatedDirIsCreated()
        {
            // Arrange
            IEducationPlanDataMapper dataMapper    = new EducationPlanJsonDataMapper(_educationPlanPath, _updatedDirPath);
            EducationPlan            educationPlan = GetDummyEducationPlan();

            educationPlan.Id = 1;
            if (Directory.Exists(_updatedDirPath))
            {
                Directory.Delete(_updatedDirPath, true);
            }

            // Act
            dataMapper.Update(educationPlan);

            // Assert no exception thrown
        }