public async Task <IActionResult> Create(Board board) { if (ModelState.IsValid) { _context.Add(board); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(board)); }
//[ValidateAntiForgeryToken] public async Task <int> Create(NoteViewModel note) { var board = _context.Boards.FindAsync(note.boardId).Result; var newNote = new Note() { x = note.x, y = note.y, width = note.width, height = note.height, Board = board, Text = string.Empty }; if (ModelState.IsValid) { _context.Add(newNote); await _context.SaveChangesAsync(); return(newNote.Id); } return(-1); }