/// <summary> /// </summary> public RegistrationResponse RegisterNewPlayer(ISession session, RegistrationRequest request) { var response = request.CreateResponse(new RegistrationResponse { Result = RegistrationResponseType.Success }); User user = null; try { user = new User(request.Name, request.Password, request.Huid, request.Sex, request.Age, request.PushUri, request.Country); user.ChangePhoto(request.PhotoId); } catch (InvalidPlayerRegistrationDataException) { response.Result = RegistrationResponseType.InvalidData; return response; } using (var uow = UnitOfWorkFactory.Create()) { if (uow.UsersRepository.AnyMatching(UserSpecification.Name(user.Name))) { response.Result = RegistrationResponseType.NameIsInUse; return response; } var playerWithSameHuid = uow.UsersRepository.FirstMatching(UserSpecification.Huid(request.Huid)); if (playerWithSameHuid != null && playerWithSameHuid.IsBanned) { response.Result = RegistrationResponseType.Banned; return response; } uow.UsersRepository.Add(user); uow.Commit(); } response.User = user.ProjectedAs<UserDto>(); return response; }
public Task<RegistrationResponse> RegisterNewPlayer(RegistrationRequest request) { return ConnectionManager.SendRequestAndWaitResponse<RegistrationResponse>(request); }