Example #1
0
        public EngageWithoutTransferAgreementResponse EngagePlayerWithoutTransferAgreement(EngageWithoutTransferAgreementRequest request)
        {
            if (!_currentUserId.HasValue)
            {
                throw new InvalidOperationException("No access");
            }

            var currentUser = _usersService.GetUserById(new GetUserByIdRequest
            {
                UserId = _currentUserId.Value
            });

            var command = new TransfersModule.Contract.EngageWithoutTransferAgreement.Request
            {
                ReleasingClubId = request.ReleasingClubId,
                PlayerId        = request.PlayerId,
                EngagingClubId  = request.EngagingClubId,
            };

            if (!AuthorizationService.CanExecuteCommand(currentUser, command))
            {
                throw new InvalidOperationException("You can only engage players for your own club");
            }

            var response = new TransfersApi().Execute(command).Result;

            return(new EngageWithoutTransferAgreementResponse
            {
                TransferId = response.TransferId
            });
        }
Example #2
0
 public static bool CanExecuteCommand(GetUserByIdResponse user, TransfersModule.Contract.EngageWithoutTransferAgreement.Request command)
 {
     return(user.ClubId == command.EngagingClubId);
 }