Ejemplo n.º 1
0
        private CourceViewModel GetCourseModel(int courseId)
        {
            ApplicationDbContext dbContext = new ApplicationDbContext();
            var _coursedb = dbContext.Courses.FirstOrDefault(x => x.Id == courseId);

            if (_coursedb != null)
            {
                var _lecture    = dbContext.Lectures.FirstOrDefault(x => x.CourseId == _coursedb.Id);
                var _seminar    = dbContext.Seminars.FirstOrDefault(x => x.CourseId == _coursedb.Id);
                var _discipline = dbContext.Disciplines.FirstOrDefault(x => x.Id == _coursedb.DisciplineId);

                var _lectureProf = dbContext.Workers.FirstOrDefault(x => x.id == _lecture.ProcessorId);
                var _seminarProf = dbContext.Workers.FirstOrDefault(x => x.id == _lecture.ProcessorId);

                var _course = new CourceViewModel
                {
                    Title          = _discipline.Title,
                    CreditCount    = _seminar.CreditCount + _lecture.CreditCount,
                    lecCreditCount = _lecture.CreditCount,
                    SemCreditCount = _seminar.CreditCount,
                    lecProfessor   = _lectureProf.LastName + " " + _lectureProf.Firstname + "(" + _lectureProf.ScienceDegree + ")",
                    semProfessor   = _seminarProf.LastName + " " + _seminarProf.Firstname + "(" + _seminarProf.ScienceDegree + ")",
                    Description    = _discipline.Description,
                    Literatures    = _discipline.Literatures,
                    CourseId       = _coursedb.Id
                };
                return(_course);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        public ActionResult MyCourses(int id)
        {
            ApplicationDbContext dbContext = new ApplicationDbContext();
            var courses        = new List <CourceViewModel>();
            var studentCourses = dbContext.StudentCources.Where(x => x.StudentId == id).ToList();
            var _courses       = new List <Course>();

            if (studentCourses.Count != 0 && studentCourses != null)
            {
                foreach (var item in studentCourses)
                {
                    _courses.Add(dbContext.Courses.FirstOrDefault(x => x.Id == item.CourceId));
                }
            }

            if (_courses.Count != 0)
            {
                try
                {
                    foreach (var item in _courses)
                    {
                        var _lecture    = dbContext.Lectures.FirstOrDefault(x => x.CourseId == item.Id);
                        var _seminar    = dbContext.Seminars.FirstOrDefault(x => x.CourseId == item.Id);
                        var _discipline = dbContext.Disciplines.FirstOrDefault(x => x.Id == item.DisciplineId);

                        var _lectureProf = dbContext.Workers.FirstOrDefault(x => x.id == _lecture.ProcessorId);
                        var _seminarProf = dbContext.Workers.FirstOrDefault(x => x.id == _lecture.ProcessorId);

                        var _course = new CourceViewModel
                        {
                            Title          = _discipline.Title,
                            CreditCount    = _seminar.CreditCount + _lecture.CreditCount,
                            lecCreditCount = _lecture.CreditCount,
                            SemCreditCount = _seminar.CreditCount,
                            lecProfessor   = _lectureProf.LastName + " " + _lectureProf.Firstname + "(" + _lectureProf.ScienceDegree + ")",
                            semProfessor   = _seminarProf.LastName + " " + _seminarProf.Firstname + "(" + _seminarProf.ScienceDegree + ")",
                            Description    = _discipline.Description,
                            Literatures    = _discipline.Literatures,
                            CourseId       = item.Id,
                            isElective     = item.IsElective
                        };
                        courses.Add(_course);
                    }
                    return(View(courses));
                }
                catch (Exception)
                {
                    ViewBag.Success = false;
                    ViewBag.Message = "Произашла ошибка при загрузке данных";
                    return(View("Result"));
                }
            }
            else
            {
                ViewBag.Success = false;
                ViewBag.Message = "Созданных курсов нет. Добавьте чтобы посмотреть";
                return(View("Result"));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Course(int applicantId, string university)
        {
            var courses = _courseService.GetCourses(university);

            var viewModel = new CourceViewModel
            {
                ApplicantId   = applicantId,
                University    = university,
                CourseHolders = courses.Select(x => BuildHolder(applicantId, x)).ToList()
            };

            return(View(viewModel));
        }
Ejemplo n.º 4
0
        public ActionResult SubscriptionRequest(int id)
        {
            ApplicationDbContext        dbContext = new ApplicationDbContext();
            CourceSubscriptionViewModel model     = new CourceSubscriptionViewModel();
            var             sub              = dbContext.CourseSubscriptionRequests.FirstOrDefault(x => x.Id == id);
            Student         _student         = dbContext.Students.FirstOrDefault(x => x.Id == sub.StudentId);
            CourceViewModel _courceViewModel = GetCourseModel(id);

            model.student = _student;
            model.cource  = _courceViewModel;
            model.status  = sub.status;
            model.SubId   = sub.Id;
            return(View(model));
        }
Ejemplo n.º 5
0
        public ActionResult StudentCourse(int id)
        {
            ApplicationDbContext dbContext = new ApplicationDbContext();
            var _coursedb = dbContext.Courses.FirstOrDefault(x => x.Id == id);

            if (_coursedb != null)
            {
                try
                {
                    var _lecture    = dbContext.Lectures.FirstOrDefault(x => x.CourseId == _coursedb.Id);
                    var _seminar    = dbContext.Seminars.FirstOrDefault(x => x.CourseId == _coursedb.Id);
                    var _discipline = dbContext.Disciplines.FirstOrDefault(x => x.Id == _coursedb.DisciplineId);

                    var _lectureProf = dbContext.Workers.FirstOrDefault(x => x.id == _lecture.ProcessorId);
                    var _seminarProf = dbContext.Workers.FirstOrDefault(x => x.id == _seminar.ProcessorId);

                    var _course = new CourceViewModel
                    {
                        Title          = _discipline.Title,
                        CreditCount    = _seminar.CreditCount + _lecture.CreditCount,
                        lecCreditCount = _lecture.CreditCount,
                        SemCreditCount = _seminar.CreditCount,
                        lecProfessor   = _lectureProf.LastName + " " + _lectureProf.Firstname + "(" + _lectureProf.ScienceDegree + ")",
                        semProfessor   = _seminarProf.LastName + " " + _seminarProf.Firstname + "(" + _seminarProf.ScienceDegree + ")",
                        Description    = _discipline.Description,
                        Literatures    = _discipline.Literatures,
                        CourseId       = _coursedb.Id
                    };

                    return(View(_course));
                }
                catch (Exception)
                {
                    ViewBag.Success = false;
                    ViewBag.Message = "Произашла ошибка при загрузке данных";
                    return(View("Result"));
                }
            }
            else
            {
                ViewBag.Success = false;
                ViewBag.Message = "Произашла ошибка при загрузке данных";
                return(View("Result"));
            }
        }
Ejemplo n.º 6
0
        public ActionResult CourseSubscriptionRequests()
        {
            ApplicationDbContext dbContext           = new ApplicationDbContext();
            List <CourceSubscriptionViewModel> model = new List <CourceSubscriptionViewModel>();

            var subs = dbContext.CourseSubscriptionRequests.ToList();

            if (subs.Count != 0 && subs != null)
            {
                foreach (var item in subs)
                {
                    Student         _student         = dbContext.Students.FirstOrDefault(x => x.Id == item.StudentId);
                    CourceViewModel _courceViewModel = GetCourseModel(item.CourseId);
                    model.Add(new CourceSubscriptionViewModel
                    {
                        student = _student,
                        cource  = _courceViewModel,
                        status  = item.status,
                        SubId   = item.Id
                    });
                }
            }
            return(View(model));
        }