Exemplo n.º 1
0
        public Transfer ConvertToTransferFromJson(TransferJson transferJson)
        {
            var transfer = new Transfer(new List <TeamTransfer>(), DateTime.UtcNow, FplDataProvider.Season);

            foreach (var teamTransferJson in transferJson.teamTransfers)
            {
                var teamTransfer = new TeamTransfer(teamTransferJson.transferredTo, new List <PlayersTransferred>());

                foreach (var playersTransferedJson in teamTransferJson.playersTransferred)
                {
                    var playerTransferred = new PlayersTransferred(playersTransferedJson.playerId, playersTransferedJson.transferredFrom);
                    teamTransfer.PlayersTransferred.Add(playerTransferred);
                }

                if (transfer.TeamTransfers.Select(x => x.TransferredTo).Contains(teamTransfer.TransferredTo))
                {
                    transfer.TeamTransfers.FirstOrDefault(x => x.TransferredTo == teamTransfer.TransferredTo).PlayersTransferred.AddRange(teamTransfer.PlayersTransferred);
                }
                else
                {
                    transfer.TeamTransfers.Add(teamTransfer);
                }
            }

            return(transfer);
        }
Exemplo n.º 2
0
        public async Task <ActionResult> TransferUserTeam(int id, TeamTransfer transfer)
        {
            System.Diagnostics.Debug.WriteLine($"TransferUserTeam: UserId: {id}, NewTeamId: {transfer.NewTeamId}");
            await _userService.TransferUserToNewTeamAsync(id, transfer);

            return(NoContent());
        }
Exemplo n.º 3
0
        public async void AddPlayersToTeam(TeamTransfer teamTransfer)
        {
            var collection = _database.GetCollection <Team>("teams");
            var filter     = Builders <Team> .Filter.Eq("_id", teamTransfer.TransferredTo);

            var idsToAdd = new List <int>();

            foreach (var playerTransfer in teamTransfer.PlayersTransferred)
            {
                idsToAdd.Add(playerTransfer.PlayerId);
            }

            var update = Builders <Team> .Update.PushEach("Players", idsToAdd);

            await collection.UpdateOneAsync(filter, update);
        }
Exemplo n.º 4
0
        public async Task <User> TransferUserToNewTeamAsync(int userId, TeamTransfer transfer)
        {
            var user = await GetUserAsync(userId);

            var team = await _teamService.GetTeamAsync(transfer.NewTeamId);

            if (team.ManagerId == user.Id)
            {
                throw new BadRequestException(Error_UserTransferManagerError);
            }

            user.TeamId = team.Id;
            _schedulearnContext.Update(user);
            await _schedulearnContext.SaveChangesAsync();

            return(user);
        }
Exemplo n.º 5
0
    void CheckEndOfList()
    {
        currentTeamIndex = (currentTeamIndex + 1) % holder.Keys.Count;

        numSelected++;

        if (numSelected >= teamSize * 2)
        {
            GameObject transferer = new GameObject();

            transferer.name = "Team Selection Data";
            TeamTransfer tt = transferer.AddComponent <TeamTransfer> ();
            tt.Teams = holder.Keys.ToList();

            DontDestroyOnLoad(transferer);

            SceneManager.LoadScene("Main");
        }
    }