public IActionResult Create(Registration registration) { ViewData["TestId"] = new SelectList(_context.Test, "Id", "Id", registration.TestId); Student student = new Student { Name = registration.Student.Name, FatherName = registration.Student.FatherName, Phone = registration.Student.Phone, Email = registration.Student.Email, Nid = registration.Student.Nid, EnteryDate = DateTime.Now }; _context.Add(student); _context.SaveChanges(); Registration _registration = new Registration() { StudentId = student.Id }; _context.Add(_registration); _context.SaveChanges(); _context.Add(registration); _context.SaveChanges(); return(View()); }
public async Task <IActionResult> Create([Bind("Id,CategoryId,QuestionTypeId,Lebel,Point,IsActive")] Question question) { if (ModelState.IsValid) { _context.Add(question); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Category, "Id", "Id", question.CategoryId); ViewData["QuestionTypeId"] = new SelectList(_context.QuestionType, "Id", "Id", question.QuestionTypeId); return(View(question)); }