Beispiel #1
0
        public async Task <IActionResult> Add([FromBody] MatchDTO match)
        {
            try
            {
                await _matchService.AddNewMatchAsync(match);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> Add([FromBody] Match match)
        {
            try
            {
                if (match.HomeTeamId == match.GuestTeamId)
                {
                    return(Conflict());
                }

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                await matchService.AddNewMatchAsync(match);

                return(CreatedAtAction("Get", new { id = match.MatchId }, match));
            }
            catch (ConstraintException)
            {
                return(StatusCode(431));
            }
            catch (AmbiguousMatchException)
            {
                return(StatusCode(429));
            }
            catch (ArgumentOutOfRangeException)
            {
                return(StatusCode(427));
            }
            catch (ArgumentException)
            {
                return(StatusCode(418));
            }
            catch (AlreadyInDatabaseException)
            {
                return(StatusCode(406));
            }
            catch (NotFoundInDatabaseException)
            {
                return(NotFound());
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }