public async Task <IActionResult> Create(TeacherCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = UploadedFile(model);

                Teacher teacher = new Teacher
                {
                    Id             = model.Id,
                    FirstName      = model.FirstName,
                    LastName       = model.LastName,
                    Degree         = model.Degree,
                    AcademicRank   = model.AcademicRank,
                    OfficeNumber   = model.OfficeNumber,
                    HireDate       = model.HireDate,
                    ProfilePicture = uniqueFileName,
                };

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

                return(RedirectToAction("Details", new { id = teacher.Id }));
            }
            return(View());
        }
Пример #2
0
        public async Task <IActionResult> Create(StudentCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = UploadedFile(model);

                Student student = new Student
                {
                    Id              = model.Id,
                    StudentId       = model.StudentId,
                    FirstName       = model.FirstName,
                    LastName        = model.LastName,
                    EnrollmentDate  = model.EnrollmentDate,
                    AcquiredCredits = model.AcquiredCredits,
                    CurrentSemester = model.CurrentSemester,
                    EducationLevel  = model.EducationLevel,
                    ProfilePicture  = uniqueFileName
                };

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

                return(RedirectToAction("Details", new { Id = student.Id }));
            }
            return(View());
        }
        public async Task <IActionResult> Create([Bind("Id,Title,Credits,Semester,Programme,EducationLevel,FirstTeacherId,SecondTeacherId")] Course course)
        {
            if (ModelState.IsValid)
            {
                _context.Add(course);
                await _context.SaveChangesAsync();

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