Exemplo n.º 1
0
        public static TournamentTeamParticipant ToTeamModel(this JoinTournamentRequest viewmodel)
        {
            TournamentTeamParticipant model = new TournamentTeamParticipant();

            model.UserID           = UserHelper.CurrentUserID;
            model.TournamentTeamID = viewmodel.TeamID ?? default(int);
            model.Registered       = DateTime.Now;

            return(model);
        }
Exemplo n.º 2
0
        private void MigrateTournamentParticipant(DataContext db, MySqlConnection conn, DataSet set, MySqlDataAdapter adapter)
        {
            adapter.SelectCommand = new MySqlCommand("select * from tournaments_participants", conn);
            adapter.Fill(set, "tournaments_participants");
            try
            {
                foreach (DataRow entry in set.Tables["tournaments_participants"].Rows)
                {
                    if (Convert.ToInt32(entry["user_id"]) == 0 || new int[] { 12, 14, 20 }.Contains(Convert.ToInt32(entry["tournament_id"])))
                    {
                        continue;
                    }
                    int tournamentTeamID = -1;
                    int offsetID         = 0;
                    try { offsetID = TupleToId(db, Convert.ToInt32(entry["user_id"])); }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Skipping Participant : {0}", Convert.ToInt32(entry["user_id"]));
                        continue;
                    }
                    if (Convert.ToInt32(entry["tournament_id"]) == 0)
                    {
                        continue;
                    }
                    int tid = Convert.ToInt32(entry["tournament_id"]) - 7;
                    if (Convert.ToInt32(entry["tournament_id"]) > 20)
                    {
                        tid -= 4;
                    }
                    else
                    if (Convert.ToInt32(entry["tournament_id"]) > 16)
                    {
                        tid -= 3;
                    }
                    else
                    if (Convert.ToInt32(entry["tournament_id"]) > 11)
                    {
                        tid -= 1;
                    }

                    if (Convert.ToInt32(entry["team_id"]) != 0)
                    {
                        MySqlDataAdapter internalAdaper = new MySqlDataAdapter();
                        DataSet          internalSet    = new DataSet();
                        internalAdaper.SelectCommand = new MySqlCommand($"Select ID from tournaments_teams where ID={Convert.ToInt32(entry["team_id"])}", conn);
                        internalAdaper.Fill(internalSet, "tournaments_teams");

                        var ID = Convert.ToInt32(internalSet.Tables["tournaments_teams"].Rows[0]["ID"]);
                        tournamentTeamID = TournamentOldToNew[ID];
                    }
                    TournamentParticipant     part1 = null;
                    TournamentTeamParticipant part2 = null;

                    var tournament = db.Tournament.Find(tid);
                    if (tournament.TeamSize > 1)
                    {
                        var participant = new TournamentTeamParticipant()
                        {
                            Registered     = GetFromMySqlDate(new MySqlDateTime(entry["registered"].ToString())).Value,
                            TournamentTeam = db.TournamentTeam.Find(tournamentTeamID),
                            UserID         = offsetID,
                        };
                        part2 = participant;
                        if (participant.TournamentTeam == null)
                        {
                            continue;
                        }
                        db.TournamentTeamParticipant.Add(participant);
                    }
                    else
                    {
                        var participant = new TournamentParticipant()
                        {
                            Registered = GetFromMySqlDate(new MySqlDateTime(entry["registered"].ToString())).Value,
                            Tournament = db.Tournament.Find(tid),
                            UserID     = offsetID,
                        };
                        part1 = participant;
                        if (participant.Tournament == null)
                        {
                            continue;
                        }
                        db.TournamentParticipant.Add(participant);
                    }
                    try {
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 3
0
        public static BackendUserViewModelItem FromModel(this BackendUserViewModelItem viewmodel, TournamentTeamParticipant model)
        {
            viewmodel.ID         = model.ID;
            viewmodel.FirstName  = model.User.FirstName;
            viewmodel.LastName   = model.User.LastName;
            viewmodel.Nickname   = model.User.Nickname;
            viewmodel.Image      = "http://lan-netconnect.de/_api/images/team/no_image.png"; // TODO
            viewmodel.Email      = model.User.Email;
            viewmodel.SteamID    = model.User.SteamID;
            viewmodel.BattleTag  = model.User.BattleTag;
            viewmodel.Newsletter = model.User.Newsletter;
            viewmodel.IsAdmin    = model.User.IsAdmin;
            viewmodel.IsTeam     = model.User.IsTeam;

            return(viewmodel);
        }
Exemplo n.º 4
0
        public static TournamentParticipantViewModelItem FromModel(this TournamentParticipantViewModelItem viewmodel, TournamentTeamParticipant model)
        {
            viewmodel.ID        = model.ID;
            viewmodel.UserID    = model.UserID;
            viewmodel.FirstName = model.User.FirstName;
            viewmodel.LastName  = model.User.LastName;
            viewmodel.Nickname  = model.User.Nickname;

            return(viewmodel);
        }