public async Task <IActionResult> Create([Bind("Name,Description,Department,Number,Semester,Year,StatusId,DueDate")] CourseInstance courseInstance, string[] instructors) { if (ModelState.IsValid) { _context.Add(courseInstance); if (instructors != null) { foreach (string instructor in instructors) { UserLocator instr = _context.UserLocator.Where(u => u.UserLoginEmail == instructor).FirstOrDefault(); if (instr != null) { _context.Instructors.Add(new Instructors() { CourseInstance = courseInstance, User = instr }); } } } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CourseInstanceId"] = new SelectList(_context.CourseInstance, "CourseInstanceId", "Department", courseInstance.CourseInstanceId); return(View(courseInstance)); }
public async Task <IActionResult> Create([Bind("Loid,Name,Description,CourseInstanceId")] LearningOutcomes learningOutcomes) { if (ModelState.IsValid) { _context.Add(learningOutcomes); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CourseInstanceId"] = new SelectList(_context.CourseInstance, "CourseInstanceId", "Department", learningOutcomes.CourseInstanceId); return(View(learningOutcomes)); }
public async Task <IActionResult> Create([Bind("Id,Text,Date,Sender,Receiver")] Messages messages) { if (ModelState.IsValid) { _context.Add(messages); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Receiver"] = new SelectList(_context.UserLocator, "Id", "UserLoginEmail", messages.Receiver); ViewData["Sender"] = new SelectList(_context.UserLocator, "Id", "UserLoginEmail", messages.Sender); return(View(messages)); }