Beispiel #1
0
        public StudyProgram AddStudyProgram(StudyProgram newStudyProgram)
        {
            using (StudentDbEntities dbContext = new StudentDbEntities())
            {
                var addStudyProgram = new tblStudyPrograms()
                {
                    Name               = newStudyProgram.Name,
                    DepartmentId       = newStudyProgram.DepartmentId,
                    BudgetPlaces       = newStudyProgram.BudgetPlaces,
                    SelffinancedPlaces = newStudyProgram.SelffinancedPlaces,
                    Tuition            = newStudyProgram.Tuition
                };

                dbContext.tblStudyPrograms.Add(addStudyProgram);
                dbContext.SaveChanges();

                var newSPId = dbContext.StudyProgramView.SingleOrDefault(x => x.StudyProgramId == addStudyProgram.StudyProgramId);

                return(new StudyProgram()
                {
                    StudyProgramId = newSPId.StudyProgramId,
                    Name = newSPId.Name,
                    DepartmentId = newSPId.DepartmentId,
                    DepartmentName = newSPId.DepartmentName,
                    BudgetPlaces = newSPId.BudgetPlaces,
                    SelffinancedPlaces = newSPId.SelffinancedPlaces,
                    Tuition = newSPId.Tuition
                });
            }
        }
        /// <summary>
        /// Related specific course with specific study program, and semester.
        /// </summary>
        /// <param name="courseId">Unique identifer for the course</param>
        /// <param name="studyProgram">Study program that needs to be related with specified course</param>
        /// <param name="semester">Semester that needs to be related with specified course</param>
        /// <returns>True if added, false if not</returns>
        public async Task <ResultMessage <bool> > AddInStudyProgram(int courseId, StudyProgram studyProgram, Semester semester)
        {
            try
            {
                CourseStudyProgram courseStudyProgram = new CourseStudyProgram()
                {
                    CourseId     = courseId,
                    Semester     = semester,
                    StudyProgram = studyProgram,
                    StudyYear    = semester.GetStudyYear()
                };
                await _orhedgeContext.AddAsync(courseStudyProgram);

                await _orhedgeContext.SaveChangesAsync();

                return(new ResultMessage <bool>(true, OperationStatus.Success));
            }
            catch (DbUpdateException ex)
            {
                return(new ResultMessage <bool>(false, _errorHandler.Handle(ex)));
            }
            catch (Exception ex)
            {
                return(new ResultMessage <bool>(false, _errorHandler.Handle(ex)));
            }
        }
        private User GetUserFromRow(MySqlDataReader reader)
        {
            User user = new User();

            UserAccountType accountType = (UserAccountType)Enum.ToObject(typeof(UserAccountType), reader.GetInt32(1));

            if (accountType is UserAccountType.Student)
            {
                Student student = new Student
                {
                    StudyYear = reader.GetInt32(6)
                };

                int?facultyId        = !reader.IsDBNull(7) ? (int?)reader.GetInt32(7) : null;
                int?programId        = !reader.IsDBNull(8) ? (int?)reader.GetInt32(8) : null;
                int?specializationId = !reader.IsDBNull(9) ? (int?)reader.GetInt32(9) : null;

                if (facultyId != null)
                {
                    Faculty faculty = ((App)App.Current).faculties.GetFacultyById((int)facultyId);

                    if (programId != null)
                    {
                        StudyProgram program = faculty.StudyPrograms[(int)programId];
                        student.StudyProgram = program;

                        if (specializationId != null)
                        {
                            StudyProgramSpecialization specialization = program.StudyProgramSpecializations[(int)specializationId];
                            student.StudyProgramSpecialization = specialization;
                        }
                    }
                }

                user = student;
            }
            else if (accountType is UserAccountType.FacultyMember)
            {
                FacultyMember facultyMember = new FacultyMember
                {
                    Faculty      = ((App)App.Current).faculties.GetFacultyById(reader.GetInt32(10)),
                    AcademicRank = (AcademicRank)Enum.ToObject(typeof(AcademicRank), reader.GetInt32(11)),
                    StudyField   = ((App)App.Current).faculties.GetStudyFieldById(reader.GetInt32(12))
                };

                user = facultyMember;
            }

            user.UserId      = reader.GetInt32(0);
            user.FirstName   = reader.GetString(2);
            user.LastName    = reader.GetString(3);
            user.PhoneNumber = !reader.IsDBNull(4) ? reader.GetString(4) : null;
            user.PhoneFormat = !reader.IsDBNull(4) ? reader.GetString(5) : null;

            return(user);
        }
 public ActionResult Edit([Bind(Include = "Id,Code,Name")] StudyProgram studyProgram)
 {
     if (ModelState.IsValid)
     {
         db.Entry(studyProgram).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(studyProgram));
 }
        public ActionResult ShowLectures()
        {
            var studentRepo    = new StudentRepo();
            var lectureRepo    = new LectureRepo();
            var model          = new StudyProgram();
            var studyProgramId = studentRepo.GetApplicationUserStudyProgramId(this.User.Identity.GetUserId());

            model.Lectures = lectureRepo.GetAllStudyProgramLectures(studyProgramId);
            return(View(model.Lectures));
        }
Beispiel #6
0
 public static Breadcrumb GetBreadcrumb(PublicDivision publicDivision, StudyProgram studyProgram)
 {
     return(new Breadcrumb()
     {
         BreadcrumbHelper.GetBreadcrumbRootItem(false),
         BreadcrumbHelper.GetBreadcrumbPublicDivisionItem(publicDivision, false),
         BreadcrumbHelper.GetBreadcrumbCourseItem(publicDivision, studyProgram, false),
         BreadcrumbHelper.GetBreadcrumbTimeTableItem()
     });
 }
        public ActionResult Create([Bind(Include = "Id,Code,Name")] StudyProgram studyProgram)
        {
            if (ModelState.IsValid)
            {
                db.StudyPrograms.Add(studyProgram);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(studyProgram));
        }
        public int GetStudyProgramId(Faculty faculty, StudyProgram studyProgram)
        {
            foreach (var item in faculty.StudyPrograms)
            {
                if (item.Value.Name == studyProgram.Name)
                {
                    return(item.Key);
                }
            }

            return(-1);
        }
        public int GetStudyProgramSpecializationId(StudyProgram program, StudyProgramSpecialization specialization)
        {
            foreach (var item in program.StudyProgramSpecializations)
            {
                if (item.Value.Name == specialization.Name)
                {
                    return(item.Key);
                }
            }

            return(-1);
        }
        // GET: StudyPrograms/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudyProgram studyProgram = db.StudyPrograms.Find(id);

            if (studyProgram == null)
            {
                return(HttpNotFound());
            }
            return(View(studyProgram));
        }
Beispiel #11
0
        public void EditStudyProgram(StudyProgram editedStudyProgram)
        {
            using (StudentDbEntities dbContext = new StudentDbEntities())
            {
                var dbStudyProgram = dbContext.tblStudyPrograms.SingleOrDefault(x => x.StudyProgramId == editedStudyProgram.StudyProgramId);

                dbStudyProgram.Name               = editedStudyProgram.Name;
                dbStudyProgram.DepartmentId       = editedStudyProgram.DepartmentId;
                dbStudyProgram.BudgetPlaces       = editedStudyProgram.BudgetPlaces;
                dbStudyProgram.SelffinancedPlaces = editedStudyProgram.SelffinancedPlaces;
                dbStudyProgram.Tuition            = editedStudyProgram.Tuition;

                dbContext.SaveChanges();
            }
        }
        public ActionResult Index()
        {
            var lectureScheduleRepo = new LectureScheduleRepo();
            var studentRepo         = new StudentRepo();
            var model          = new StudyProgram();
            var studyProgramId = studentRepo.GetApplicationUserStudyProgramId(this.User.Identity.GetUserId());
            var lectureIdList  = lectureScheduleRepo.GetAllStudyProgramLectures(DateTime.Today, studyProgramId);
            var lectureRepo    = new LectureRepo();
            var lectureList    = new List <Lecture>();

            for (int i = 0; i < lectureIdList.Count; i++)
            {
                lectureList.Add(lectureRepo.GetLecturesById(lectureIdList[i]));
            }
            model.Lectures = lectureList;
            return(View(model.Lectures));
        }
Beispiel #13
0
        public AddStudyProgramViewModel(AddStudyProgramView view, StudyProgram editSP, IEventAggregator eventArgs)
        {
            this.editSP    = editSP;
            this.view      = view;
            this.eventArgs = eventArgs;

            Departments = new ObservableCollection <Department>(ServiceDataProvider.GetAllDepartments());

            if (editSP != null)
            {
                Name               = editSP.Name;
                DepartmentId       = editSP.DepartmentId;
                SelffinancedPlaces = editSP.SelffinancedPlaces;
                BudgetPlaces       = editSP.BudgetPlaces;
                Tuition            = editSP.Tuition;
            }
        }
Beispiel #14
0
        public async void ProgramChosenAsync(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
        {
            string programName = (string)args.SelectedItem;

            StudentProfileInputModel.StudyProgramName = programName;

            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                          () =>
            {
                SpecializationNames.Clear();
                StudyProgram studyProgram = ((App)App.Current).faculties.GetAll().First(f => f.Name == StudentProfileInputModel.FacultyName)
                                            .StudyPrograms.Values.First(sp => sp.Name == programName);
                var specializationNames = studyProgram.StudyProgramSpecializations.Values.Select(sps => sps.Name);

                StudyYears.Clear();
                for (int i = 1; i <= studyProgram.DurationYears; i++)
                {
                    StudyYears.Add(i);
                }
            });
        }
Beispiel #15
0
        private void ExecuteSave(object param)
        {
            try
            {
                if (editSP != null)
                {
                    editSP.Name               = Name;
                    editSP.DepartmentId       = DepartmentId;
                    editSP.SelffinancedPlaces = SelffinancedPlaces;
                    editSP.BudgetPlaces       = BudgetPlaces;
                    editSP.Tuition            = Tuition;

                    ServiceDataProvider.EditStudyProgram(editSP);
                    eventArgs.GetEvent <StudyProgramEvent>().Publish(editSP);
                }
                else
                {
                    StudyProgram newStudyProgram = new StudyProgram()
                    {
                        Name               = Name,
                        DepartmentId       = DepartmentId,
                        SelffinancedPlaces = SelffinancedPlaces,
                        BudgetPlaces       = BudgetPlaces,
                        Tuition            = Tuition
                    };

                    ServiceDataProvider.AddStudyProgram(newStudyProgram);
                }
            }
            catch (Exception e)
            {
                e.Message.ToString();
            }
            finally
            {
                view.Close();
            }
        }
Beispiel #16
0
        public IEnumerable <StudyProgram> GetAllSPForDepartmentId(int departmentId)
        {
            using (StudentDbEntities dbContext = new StudentDbEntities())
            {
                var spList = (from sp in dbContext.tblStudyPrograms where sp.DepartmentId == departmentId select sp).ToList();

                ICollection <StudyProgram> studyPrograms = new List <StudyProgram>(spList.Count);

                foreach (var sp in spList)
                {
                    StudyProgram departmentSP = new StudyProgram()
                    {
                        StudyProgramId = sp.StudyProgramId,
                        DepartmentId   = sp.DepartmentId,
                        Name           = sp.Name
                    };

                    studyPrograms.Add(departmentSP);
                }

                return(studyPrograms);
            }
        }
Beispiel #17
0
        public IEnumerable <StudyProgram> GetAllStudyPrograms()
        {
            using (StudentDbEntities dbContext = new StudentDbEntities())
            {
                var dbStudyPrograms = dbContext.StudyProgramView.ToList();
                List <StudyProgram> studyPrograms = new List <StudyProgram>(dbStudyPrograms.Count);

                foreach (var dbStudyProgram in dbStudyPrograms)
                {
                    StudyProgram studyProgram = new StudyProgram();
                    studyProgram.StudyProgramId     = dbStudyProgram.StudyProgramId;
                    studyProgram.Name               = dbStudyProgram.Name;
                    studyProgram.DepartmentId       = dbStudyProgram.DepartmentId;
                    studyProgram.DepartmentName     = dbStudyProgram.DepartmentName;
                    studyProgram.SelffinancedPlaces = dbStudyProgram.SelffinancedPlaces;
                    studyProgram.BudgetPlaces       = dbStudyProgram.BudgetPlaces;
                    studyProgram.Tuition            = dbStudyProgram.Tuition;

                    studyPrograms.Add(studyProgram);
                }

                return(studyPrograms);
            }
        }
        /// <summary>
        /// Adds course in database, as well as specified categories that need to be related to added course.
        /// It also relates course with specific study program and semester.
        /// This method is defined in transaction scope.
        /// </summary>
        /// <param name="name">Name of the course to add</param>
        /// <param name="categories">List of the names of the categories that needs be added</param>
        /// <param name="semester">Belonging semester</param>
        /// <param name="studyProgram">Belonging study program</param>
        /// <returns>True if added, false if not.</returns>
        public async Task <ResultMessage <bool> > SaveCourse(string name, string[] categories, Semester semester, StudyProgram studyProgram)
        {
            try
            {
                using (IDbContextTransaction transaction = await _orhedgeContext.Database.BeginTransactionAsync())
                {
                    ResultMessage <CourseDTO> addedCourse = await _courseService.Add(new CourseDTO()
                    {
                        Name = name
                    });

                    if (!addedCourse.IsSuccess)
                    {
                        return(new ResultMessage <bool>(false, addedCourse.Status, addedCourse.Message));
                    }
                    foreach (string category in categories)
                    {
                        ResultMessage <CategoryDTO> addedCategory = await _categoryService.Add(
                            new CategoryDTO()
                        {
                            CourseId = addedCourse.Result.CourseId,
                            Name     = category
                        });

                        if (!addedCategory.IsSuccess)
                        {
                            return(new ResultMessage <bool>(false, addedCategory.Status, addedCategory.Message));
                        }
                    }
                    ResultMessage <bool> sp = await AddInStudyProgram(addedCourse.Result.CourseId, studyProgram, semester);

                    if (!sp.IsSuccess)
                    {
                        return(sp);
                    }
                    transaction.Commit();
                    return(new ResultMessage <bool>(true, OperationStatus.Success));
                }
            }
            catch (DbUpdateException ex)
            {
                return(new ResultMessage <bool>(false, _errorHandler.Handle(ex)));
            }
        }
        /// <summary>
        /// Deletes course from study program and within certain semester.
        /// </summary>
        /// <param name="courseId">Unique identifer for the course</param>
        /// <param name="studyProgram">Study program from which course is being deleted</param>
        /// <param name="semester">Semester from which course if being deleted</param>
        /// <returns>True if deleted, false if not</returns>
        public async Task <ResultMessage <bool> > DeleteFromStudyProgram(int courseId, StudyProgram studyProgram, Semester semester)
        {
            try
            {
                CourseStudyProgram courseStudyProgram = await _orhedgeContext.CourseStudyPrograms
                                                        .SingleOrDefaultAsync(x => x.CourseId == courseId &&
                                                                              x.StudyProgram == studyProgram &&
                                                                              x.Semester == semester);

                if (courseStudyProgram == null)
                {
                    return(new ResultMessage <bool>(false, OperationStatus.NotFound));
                }
                _orhedgeContext.Remove(courseStudyProgram);
                await _orhedgeContext.SaveChangesAsync();

                return(new ResultMessage <bool>(true, OperationStatus.Success));
            }
            catch (DbUpdateException ex)
            {
                return(new ResultMessage <bool>(false, _errorHandler.Handle(ex)));
            }
            catch (Exception ex)
            {
                return(new ResultMessage <bool>(false, _errorHandler.Handle(ex)));
            }
        }
Beispiel #20
0
 public AddStudyProgramView(StudyProgram sp = null)
 {
     InitializeComponent();
     DataContext = new AddStudyProgramViewModel(this, sp, ApplicationService.Instance.EventAggregator);
 }
Beispiel #21
0
 private static string GetCourseItemDisplayText(LanguageCode language, StudyProgram studyProgram)
 {
     return(String.Format("{0} \"{1}\"", Resources.Resources.Program, studyProgram.GetNameByLanguage(language)));
 }
 public StudyProgramEventArgs(StudyProgram sp)
 {
     this.sp = sp;
 }
Beispiel #23
0
        public StudyProgram GetProgram(Guid id, int no)
        {
            _curr = _db.Curricula.SingleOrDefault(x => x.Id == id);

            _prog = new StudyProgram
            {
                id       = no,
                name     = _curr.Name,
                shortcut = _curr.ShortName,
                modules  = new List <StudyProgramModule>(),
                rules    = new List <StudyProgramRuleSet>()
            };

            // alle Module bauen
            // Grundidee => Ein kriterium entspricht dem Modul
            // Erstmal ohne Studienrichtung, d.h. immer das erste Paket
            foreach (var pck in _curr.Packages)
            {
                foreach (var req in pck.Options.First().Requirements)
                {
                    // nicht nach Kriterien aufspalten
                    // immer das erste nehmen
                    AddCriteria(req.Criterias.First());
                }
            }
            // spezielle Abfragen
            // ects => summe ects module
            _prog.ects = _prog.modules.Sum(x => x.ects);
            // Studiendauer = höchste semesternummer
            _prog.standardStudyPeriod = _prog.modules.Max(x => x.regularSemester);

            // praktisches Semester => Name einer Anforderung "Praktikum"
            var critPract = _prog.modules.SingleOrDefault(x => x.title.Equals("Praktikum"));

            if (critPract != null)
            {
                _prog.practicalSemester = critPract.regularSemester;
            }

            // Jetzt die Regeln
            // Fakes
            var ruleSet = new StudyProgramRuleSet
            {
                studyProgramId = _prog.id,
                startRules     = new List <StudyProgramStartRule>(),
                riseRules      = new List <StudyProgramRiseRule>(),
                Prequisites    = new List <StudyProgramPrequisite>(),
                retryDeadlines = new StudyProgramRetryDeadlines
                {
                    first              = 1,
                    second             = 2,
                    maxSecondFailCount = 5
                }
            };

            _prog.rules.Add(ruleSet);

            InitRules();

            return(_prog);
        }
 public static void EditStudyProgram(StudyProgram editSP)
 {
     proxy.EditStudyProgram(editSP);
 }
        public static void AddStudyProgram(StudyProgram sp)
        {
            var newStudyProgram = proxy.AddStudyProgram(sp);

            AddStudyProgramNotification?.Invoke(typeof(ServiceDataProvider), new StudyProgramEventArgs(newStudyProgram));
        }
Beispiel #26
0
 public static List <CourseDTO> GetCourses(this DetailedSemesterDTO semester, StudyProgram studyProgram)
 {
     return(semester.Courses[studyProgram]);
 }
Beispiel #27
0
 public static List <IndexCourseViewModel> GetCourses(this SemesterViewModel semester, StudyProgram studyProgram)
 {
     return(semester.Courses[studyProgram]);
 }
Beispiel #28
0
        public static BreadcrumbItem GetBreadcrumbCourseItem(PublicDivision publicDivision, StudyProgram studyProgram, bool isActive)
        {
            var language = CultureHelper.CurrentLanguage;

            return(new BreadcrumbItem
            {
                IsActive = isActive,
                DisplayText = GetCourseItemDisplayText(language, studyProgram),
                ActionName = "Show",
                ControllerName = "StudyProgram",
                RouteValues = new RouteValueDictionary(new Dictionary <string, object> {
                    { "publicDivisionAlias", publicDivision.Alias },
                    { "id", studyProgram.Id }
                }),
                HtmlAttributes = null
            });
        }
Beispiel #29
0
        private static string GetStudyProgramDisplayText(StudyProgram studyProgram)
        {
            var language = CultureHelper.CurrentLanguage;

            return(String.Concat(Resources.Resources.StudyProgram, " ", studyProgram.GetNameByLanguage(language)));
        }