Пример #1
0
        public async Task <IActionResult> Create(TeacherFormVm 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,

                    FirstCourses  = Vmodel.FirstCourses,
                    SecondCourses = Vmodel.SecondCourses
                };

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

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
Пример #2
0
        public async Task <IActionResult> Create(StudentFormVM Vmodel)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = UploadedFile(Vmodel);

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

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

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
        public async Task <IActionResult> PutCourse(int id, Course course)
        {
            if (id != course.Id)
            {
                return(BadRequest());
            }

            _context.Entry(course).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CourseExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutTeacher(int id, Teacher teacher)
        {
            if (id != teacher.Id)
            {
                return(BadRequest());
            }

            _context.Entry(teacher).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TeacherExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #5
0
        public async Task <IActionResult> PutEnrollment(int id, Enrollment enrollment)
        {
            if (id != enrollment.Id)
            {
                return(BadRequest());
            }

            _context.Entry(enrollment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EnrollmentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #6
0
        public async Task <IActionResult> Create([Bind("Id,CourseId,StudentId,Semester,Year,Grade,SeminarUrl,ProjectUrl,ExamPoints,SeminarPoints,ProjectPoints,AdditionalPoints,FinishDate")] Enrollment enrollment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(enrollment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"]  = new SelectList(_context.Course, "Id", "Title", enrollment.CourseId);
            ViewData["StudentId"] = new SelectList(_context.Student, "Id", "FirstName", enrollment.StudentId);
            return(View(enrollment));
        }
Пример #7
0
        public async Task <IActionResult> Create([Bind("Id,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));
        }