Ejemplo n.º 1
0
        public async Task <IActionResult> EnrollStudents(EnrollStudentsViewModel entry)
        {
            Course course = await _context.Courses.FirstOrDefaultAsync(c => c.Id == entry.CourseId);

            if (course == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                foreach (int sId in entry.StudentIds)
                {
                    Enrollment enrollment = await _context.Enrollments
                                            .FirstOrDefaultAsync(c => c.CourseId == entry.CourseId && c.StudentId == sId &&
                                                                 c.Year == entry.Year && c.Semester == entry.Semester);

                    if (enrollment == null)
                    {
                        enrollment = new Enrollment
                        {
                            CourseId  = entry.CourseId,
                            StudentId = sId,
                            Year      = entry.Year,
                            Semester  = entry.Semester
                        };
                        _context.Add(enrollment);
                    }
                }
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { sTitle = course.Title, sSem = entry.Semester, sYear = entry.Year }));
            }
            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("EnrollmentID,CourseID,StudentID,Semestar,Grade,Year,SeminalUrl,ProjectUrl,ExamPoints,SeminalPoints,ProjectPoints,AdditionalPoints,FinishDate")] Enrollment enrollment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(enrollment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseID"]  = new SelectList(_context.Courses, "CourseID", "Title", enrollment.CourseID);
            ViewData["StudentID"] = new SelectList(_context.Students, "Id", "FullName", enrollment.StudentID);
            return(View(enrollment));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create(StudentForm Vmodel)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = UploadedFile(Vmodel);

                Student student = new Student
                {
                    ProfilePicture  = uniqueFileName,
                    StudentId       = Vmodel.Index,
                    FirstName       = Vmodel.FirstName,
                    LastName        = Vmodel.LastName,
                    EnrollmentDate  = Vmodel.EnrollmentDate,
                    AcquiredCredits = Vmodel.AcquiredCredits,
                    CurrentSemestar = Vmodel.CurrentSemestar,
                    EducationLevel  = Vmodel.EducationLevel,
                    Enrollments     = Vmodel.Courses,
                };

                _context.Add(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create(TeacherForm Vmodel)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = UploadedFile(Vmodel);

                Teacher teacher = new Teacher
                {
                    ProfilePicture = uniqueFileName,
                    FirstName      = Vmodel.FirstName,
                    LastName       = Vmodel.LastName,
                    Degree         = Vmodel.Degree,
                    AcademicRank   = Vmodel.AcademicRank,
                    OfficeNumber   = Vmodel.OfficeNumber,
                    HireDate       = Vmodel.HireDate,

                    Course1 = Vmodel.Courses_first,
                    Course2 = Vmodel.Courses_second
                };

                _context.Add(teacher);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,StudentId,FirstName,LastName,EnrollmentDate,AcquiredCredits,CurrentSemester,EducationLevel")] Student student)
        {
            if (ModelState.IsValid)
            {
                _context.Add(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Enroll(int?studentId, int?labId)
        {
            if ((studentId == null) || (labId == null))
            {
                return(NotFound());
            }

            Student toInsert = await _context.students.AsQueryable().Where(s => s.Id == studentId).FirstOrDefaultAsync();

            Labvezba toPut = await _context.vezbi.AsQueryable().Where(s => s.Id == labId).FirstOrDefaultAsync();

            Studentlab nov_lab = new Studentlab {
                studentId = (int)studentId, student = toInsert, labvezbaId = (int)labId, vezba = toPut
            };

            _context.Add(nov_lab);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Degree,AcademicRank,OfficeNumber,HireDate")] Teacher teacher)
        {
            if (ModelState.IsValid)
            {
                _context.Add(teacher);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(teacher));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("Id,title,desc")] Labvezba labvezba)
        {
            if (ModelState.IsValid)
            {
                _context.Add(labvezba);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(labvezba));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Create([Bind("CourseID,Title,Credits,Semestar,Programme,EducationLevel,FirstTeacherId,SecondTeacherId")] Course course)
        {
            if (ModelState.IsValid)
            {
                _context.Add(course);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FirstTeacherID"]  = new SelectList(_context.Set <Teacher>(), "Id", "FullName", course.FirstTeacherId);
            ViewData["SecondTeacherID"] = new SelectList(_context.Set <Teacher>(), "Id", "FullName", course.SecondTeacherId);
            return(View(course));
        }