コード例 #1
0
        public async Task <ActionResult <Game> > PostGame(Game game)
        {
            try
            {
                await _gamesService.CreateGameAsync(game);
            }
            catch (ArgumentNullException ex)
            {
                return(BadRequest(ex.Message));
            }

            return(CreatedAtAction("GetGame", new { id = game.Id }, game));
        }
コード例 #2
0
        public async Task <IActionResult> OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Game.PhotoUrl = await _storageService.UploadPhoto(FileManager.FormFile);

            await _gameService.CreateGameAsync(Game);

            return(RedirectToPage("./Games"));
        }