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()); }
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> 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)); }
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)); }