Beispiel #1
0
        public async Task <IActionResult> AddNewGamer(
            [FromBody] GamerCreateBinding binding,
            [FromServices] Domain.UserRegistration.IUserRegistrationRepository userRepository,
            [FromServices] UserRegistrarService gamerFactory,
            CancellationToken cancellationToken)
        {
            try{
                var user = await gamerFactory.Create(binding.Id, HttpContext.GetGuildId(), binding.Login, binding.Name, binding.DateOfBirth, binding.Rank,
                                                     binding.Status, cancellationToken);

                await userRepository.Save(user, cancellationToken);

                return(Ok(new { }));
            }
            catch (UserAlreadyExistsException) {
                throw new ApiException(HttpStatusCode.Conflict, ErrorCodes.GamerAlreadyExists, "Gamer already exists");
            }
        }