public async Task <IActionResult> Create(StudentFormViewModel model) { if (ModelState.IsValid) { string uniqueFileName = UploadedFile(model); Student student = new Student { Index = model.Index, FirstName = model.FirstName, LastName = model.LastName, EnrollmentDate = model.EnrollmentDate, AcquiredCredits = model.AcquiredCredits, CurrentSemestar = model.CurrentSemestar, ProfilePicture = uniqueFileName, EducationLevel = model.EducationLevel, Courses = model.Courses }; _context.Add(student); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View()); }
public async Task <IActionResult> Create(TeacherFormViewModel model) { if (ModelState.IsValid) { string uniqueFileName = UploadedFile(model); Teacher teacher = new Teacher { FirstName = model.FirstName, LastName = model.LastName, Degree = model.Degree, AcademicRank = model.AcademicRank, OfficeNumber = model.OfficeNumber, HireDate = model.HireDate, ProfilePicture = uniqueFileName, Courses_first = model.Courses_first, Courses_second = model.Courses_second }; _context.Add(teacher); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View()); }
public async Task <IActionResult> Create([Bind("Id,Semester,Year,Grade,SeminalUrl,ProjectUrl,ExamPoints,SeminalPoints,ProjectPoints,AdditionalPoints,FinishDate,CourseId,StudentId")] 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)); }
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)); }