コード例 #1
0
        private async Task <List <string> > CreateAthletes(int numberAthletesPerTeam, int teamId)
        {
            List <string> athleteNames = new List <string>();

            for (int j = 0; j < numberAthletesPerTeam; j++)
            {
                var athlete = stackOfAthletes.Pop();
                athlete.TeamId = teamId;
                await athleteRepository.CreateAthleteAsync(athlete);

                athleteNames.Add(athlete.Name);
            }

            return(athleteNames);
        }
コード例 #2
0
        public async Task <ActionResult> Create(Athlete athlete)
        {
            try
            {
                await repository.CreateAthleteAsync(athlete);
            }
            catch (Exception e)
            {
                return(BadRequest(new
                {
                    error = string.Format("Parâmetros inválidos - Error {0}", e.Message)
                }));
            }

            return(RedirectToAction("Get", new { id = athlete.Id }));
        }