Esempio n. 1
0
        public async Task <IActionResult> Create(Time time)
        {
            if (!ModelState.IsValid)
            {
                return(View(time));
            }

            await _timeRepositorio.CadastrarTime(time);

            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public async Task <IActionResult> Post([FromBody] Time time)
        {
            try
            {
                var timeCadastrado = await _timeRepositorio.CadastrarTime(time);

                return(CreatedAtRoute(routeName: "GetTimes",
                                      routeValues: new { id = timeCadastrado.Id },
                                      value: timeCadastrado));
            }
            catch (NaoEPossivelCadastrarTimeComIdJaExistenteException)
            {
                return(StatusCode(StatusCodes.Status409Conflict));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }