コード例 #1
0
        public async Task <ActionResult <Platform> > PostPlatform(Platform platform)
        {
            try
            {
                await _platformService.CreatePlatformAsync(platform);
            }
            catch (ArgumentNullException ex)
            {
                return(BadRequest(ex.Message));
            }

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

            try
            {
                await _platformService.CreatePlatformAsync(Platform);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }

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