public async Task AddContactToClub(string clubName, Pilot pilot)
        {
            var exist    = _clubMemberRepository.AddPilot(pilot);
            var clubSpec = new ClubWithSpecification(clubName);

            Club club = await(_clubRepository.GetAllByIdAsync(clubSpec));

            //clubSpec = new ClubWithSpecification(clubName, ClubServiceSpec.IncludePhone);
            //club1 = club1 = (await _clubRepository.ListAsync(clubSpec));
            //clubSpec = new ClubWithSpecification(clubName, ClubServiceSpec.IncludeEmail);
            //club1 = club1 = (await _clubRepository.ListAsync(clubSpec));


            club.AddMember(pilot);



            await _clubRepository.AddAsync(club);
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([FromBody] DTO.Club.Input.Club club)
        {
            var clubResult = await _clubRepository.AddAsync(new Models.Club.Club()
            {
                FullName = club.FullName
            });

            var result = AutoMapper.Mapper.Map <DTO.Club.Output.Club>(clubResult);

            return(Ok(result));
        }
        public async Task <IActionResult> Register(SignUpRequest signUpRequest)
        {
            var user = await _userService.GetUserByEmail(signUpRequest.Email);

            if (user != null)
            {
                return(BadRequest(ResponseMessage.UserExsits()));
            }

            var newUser = new ApplicationUser()
            {
                UserName = $"{signUpRequest.FirstName}",
                Email    = signUpRequest.Email,
            };

            var createdUser = await _userService.CreateUser(newUser, signUpRequest.Password);

            if (!createdUser.Succeeded)
            {
                return(BadRequest(createdUser.Errors));
            }

            var clubResult = await _clubRepository.AddAsync(new Models.Club.Club()
            {
                FullName = signUpRequest.ClubName
            });

            var userhehe = await _userService.GetUserByEmail(signUpRequest.Email);

            var applicationUserInClub = await _applicationUserClubRepository.AddAsync(new ApplicationUserClub()
            {
                ApplicationUserId = userhehe.Id,
                ClubId            = clubResult.Id
            });

            _logger.LogInformation($"User created a new account with email: {signUpRequest.Email}");

            return(Ok());
        }
Esempio n. 4
0
 public async Task <int> Add(Club model)
 {
     return(await _clubRepository.AddAsync(model));
 }