Example #1
0
        public async Task <ActionResult <Mode> > PostMode(Mode mode)
        {
            try
            {
                await _modeService.CreateModeAsync(mode);
            }
            catch (ArgumentNullException ex)
            {
                return(BadRequest(ex.Message));
            }

            return(CreatedAtAction("GetMode", new { id = mode.Id }, mode));
        }
Example #2
0
        public async Task <IActionResult> OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            try
            {
                await _modeService.CreateModeAsync(Mode);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }

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