public async Task <IActionResult> Create([Bind("Id,Statement,Formulation,Rank,ExerciseId")] Queries queries) { if (ModelState.IsValid) { _context.Add(queries); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ExerciseId"] = new SelectList(_context.Exercises, "Id", "Title", queries.ExerciseId); return(View(queries)); }
//[ValidateAntiForgeryToken] public int Create([FromBody] Exercises exercises) { if (ModelState.IsValid) { _context.Add(exercises); _context.SaveChanges(); return(_context.Exercises.Max(item => item.Id)); } return(0); }