예제 #1
0
        public static async Task CheckIfAthleteAsync(this IAthleteRepository repository, User user, string roleName)
        {
            var athlete = await repository.GetAsync(user.Id);

            if (athlete is null && roleName != RoleId.Admin.ToString())
            {
                athlete = new Athlete(user);
                await repository.AddAsync(athlete);
            }
        }
예제 #2
0
        public async Task <int> CreateAsync(int userId)
        {
            var user = await _userRepository.GetOrFailAsync(userId);

            var athlete = await _athleteRepository.FindByCondition(a => a.UserId == userId);

            if (athlete != null)
            {
                throw new AthleteExistsException(userId);
            }

            athlete = new Athlete(user);

            await _athleteRepository.AddAsync(athlete);

            return(athlete.Id);
        }