public async Task <ActionResult <BinaryLauncher> > EditBinaryLauncher([FromBody] BinaryLauncher launcher)
 {
     try
     {
         return(await _context.EditBinaryLauncher(launcher));
     }
     catch (ControllerNotFoundException e)
     {
         return(NotFound(e.Message));
     }
     catch (ControllerBadRequestException e)
     {
         return(BadRequest(e.Message));
     }
 }
示例#2
0
        public async Task <IActionResult> Binary(BinaryLauncher launcher)
        {
            try
            {
                launcher = await _context.EditBinaryLauncher(launcher);

                launcher = await _context.GenerateBinaryLauncher();

                ViewBag.Launcher  = launcher;
                ViewBag.Listeners = await _context.GetListeners();

                return(RedirectToAction(nameof(Create), new { id = launcher.Name }));
            }
            catch (Exception e) when(e is ControllerNotFoundException || e is ControllerBadRequestException || e is ControllerUnauthorizedException)
            {
                ModelState.AddModelError(string.Empty, e.Message);
                ViewBag.Launcher  = launcher;
                ViewBag.Listeners = await _context.GetListeners();

                return(RedirectToAction(nameof(Create), new { id = launcher.Name }));
            }
        }