Пример #1
0
        public ActionResult CreateCompetitor(int raceId, int runnerId, int seconds)
        {
            try
            {
                var newCompetitor = _repository.AddCompetitor(runnerId, seconds, raceId);

                if (_repository.SaveAll())
                {
                    return(Created($"/races/{raceId}", newCompetitor));
                }
                else
                {
                    return(BadRequest("Failed to save competitor."));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Failed to save new competitor: {ex}");
                return(BadRequest("Failed to save competitor."));
            }
        }