Example #1
0
        void AddSpeakersToList(Debater judge,
                               List <int> list,
                               Widget e)
        {
            int i = 0;

            if (e is Container)               // might also be a dummy label
            {
                bool      isTeam = e is Team; // might also be a table (=cFreeSpeakers
                Container c      = (Container)(isTeam ? ((Team)e).GetVboxTeamMembers() : e);
                foreach (Widget w in c)
                {
                    if (w is DebaterWidget)
                    {
                        int conflict = GetJudgeVsSpeaker(judge, (DebaterWidget)w);
                        // cFreeSpeakers as table iterates over debater widgets in
                        // reverse order than vbox/hbox containers, so correct that
                        if (isTeam)
                        {
                            list.Add(conflict);
                        }
                        else
                        {
                            list.Insert(3, conflict);                             // i=3 is first freeSpeaker index
                        }
                        i++;
                    }
                }
            }
            // always pad with zeros...(if we have an imcomplete room)
            for (int j = i; j < 3; j++)
            {
                list.Add(0);
            }
        }
Example #2
0
        // GET: Debaters
        public async Task <IActionResult> Index()
        {
            var     currentUserId = this.User.FindFirstValue(ClaimTypes.NameIdentifier).ToString();
            Debater debater       = _context.Debater.FirstOrDefault(d => d.ApplicationUserId == currentUserId);

            return(View(debater));
        }
Example #3
0
        public async Task <IActionResult> Edit(int id, [Bind("DebaterId,FirstName,LastName,Email,PhoneNumber,CoachId,PartnerId,SchoolId,IndividualRoundSpeakerPoints,IndividualTournamentSpeakerPoints,AnnualAverageSpeakerPoints,ApplicationUserId")] Debater debater)
        {
            if (id != debater.DebaterId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(debater);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DebaterExists(debater.DebaterId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("ManageTeam", "Coaches"));
            }
            return(View(debater));
        }
Example #4
0
        void UpdateJudges()
        {
            RoundResultData.UpdateStats();
            MiscHelpers.ClearTable(tableJudges);
            List <Debater> judges = new List <Debater>();

            foreach (Debater d in Tournament.I.Debaters)
            {
                if (d.Role.IsJudge)
                {
                    judges.Add(d);
                }
            }
            judges.Sort(delegate(Debater a, Debater b) {
                return(b.StatsAvg[0].CompareTo(a.StatsAvg[0]));
            });
            for (uint pos = 0; pos < judges.Count; pos++)
            {
                Debater j = judges[(int)pos];
                tableJudges.Attach(new DebaterWidget(new RoundDebater(j)),
                                   0, 1,
                                   2 * pos + 1, 2 * pos + 2,
                                   AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                Label lbl1 = new Label();
                lbl1.Markup = "<big><b>" +
                              RoundResultData.StatAsString(j.StatsAvg[0]) + "&#177;" +
                              RoundResultData.ErrAsString(j.StatsAvg[1]) + "</b></big>";
                lbl1.Xalign = 0;
                tableJudges.Attach(lbl1,
                                   1, 2,
                                   2 * pos + 1, 2 * pos + 2,
                                   AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                Label lbl2 = new Label();
                lbl2.Markup = "<big><b>" +
                              RoundResultData.StatAsString(j.StatsAvg[2]) + "</b></big>";
                lbl2.Xalign = 0;
                tableJudges.Attach(lbl2,
                                   2, 3,
                                   2 * pos + 1, 2 * pos + 2,
                                   AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                if (pos < judges.Count - 1)
                {
                    Debater jNext = judges[(int)(pos + 1)];
                    double  diff  = j.StatsAvg[0] - jNext.StatsAvg[0];
                    if (double.IsNaN(diff))
                    {
                        diff = 0;
                    }
                    int pixels = 5 * (int)Math.Round(diff * 10);
                    tableJudges.Attach(MyGridLine.H(pixels + 3),
                                       0, 3,
                                       2 * pos + 2, 2 * pos + 3,
                                       AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                }
            }

            tableJudges.ShowAll();
        }
Example #5
0
        // the nine integers indicate conflict (-1), nothing (0) and already seen (>0)
        public List <int> GetJudgeMatrixPattern(Debater judge)
        {
            List <int> list = new List <int>();

            AddSpeakersToList(judge, list, cGov.Child);
            AddSpeakersToList(judge, list, cFreeSpeakers);
            AddSpeakersToList(judge, list, cOpp.Child);
            return(list);
        }
Example #6
0
        public DebaterWidget(RoundDebater rd, bool canFocus, bool showDebaterName)
        {
            this.Build();
            roundDebater = rd;
            debater      = null;
            debaterValid = false;
            infoWidgets  = new Dictionary <string, Widget>();

            if (roundDebater == null)
            {
                Label lbl = new Label();
                lbl.Markup = "<i>No Debater</i>";
                lbl.Xalign = 0f;
                alBtn.Add(lbl);
                alBtn.ShowAll();
                MiscHelpers.SetIsShown(hboxInfo, false);
                return;
            }

            // btnExpand Setup
            btnExpand = new MyButton(this, rd.Name.ToString(),
                                     "weather-clear", "weather-clear-night");
            btnExpand.CanFocus = canFocus;
            btnExpand.Clicked += OnBtnExpandClicked;
            alBtn.Add(btnExpand);
            alBtn.ShowAll();

            // infoLabels Setup
            SetupInfo(showDebaterName);

            // conflict notifications
            btnConflict = new MyConflictButton();
            alConflictBtn.Add(btnConflict);

            //  (default not shown,
            // activated by ShowJudgeAvail from DebaterPool)
            btnJudgeState = new MyJudgeStateButton(roundDebater);
            btnExpand.SetStrikeThrough(!rd.JudgeAvail);
            btnJudgeState.Changed += delegate {
                btnExpand.SetStrikeThrough(!rd.JudgeAvail);
                if (JudgeStateChanged != null)
                {
                    JudgeStateChanged(this, EventArgs.Empty);
                }
            };
            alJudgeState.Add(btnJudgeState);
            alJudgeState.NoShowAll = true;

            // SetIsShown in Realized so that everything is counted correctly by triggered events
            Realized += delegate(object sender, EventArgs e) {
                MiscHelpers.SetIsShown(this, roundDebater.IsShown);
                MiscHelpers.SetIsShown(hboxInfo, false);
            };
        }
Example #7
0
        // GET: Debaters/Edit/5
        public IActionResult Edit()
        {
            var     currentUserId = this.User.FindFirstValue(ClaimTypes.NameIdentifier).ToString();
            var     currentUser   = _context.Users.FirstOrDefault(u => u.Id == currentUserId);
            Debater debater       = _context.Debater.Where(d => d.Email == currentUser.Email).Single();

            debater.ApplicationUserId = currentUserId;
            _context.Update(debater);
            _context.SaveChanges();
            return(RedirectToAction("RegistrationConfirmation", "Home"));
        }
Example #8
0
 public void UpdateInfo()
 {
     if (!btnExpand.Toggled)
     {
         return;
     }
     if (Debater != null)
     {
         SetMarkup(infoWidgets["roundResults"], SmallText(Debater.RoundResultsAsMarkup()));
     }
 }
Example #9
0
        public async Task <IActionResult> Create([Bind("DebaterId,FirstName,LastName,Email,PhoneNumber,CoachId,PartnerId,SchoolId,IndividualRoundSpeakerPoints,IndividualTournamentSpeakerPoints,AnnualAverageSpeakerPoints,ApplicationUserId")] Debater debater /*, string Id*/)
        {
            if (ModelState.IsValid)
            {
                //debater.ApplicationUserId = Id;
                var currentUserId = this.User.FindFirstValue(ClaimTypes.NameIdentifier).ToString();
                var currentCoach  = _context.Coach.FirstOrDefault(t => t.ApplicationUserId == currentUserId);
                debater.CoachId  = currentCoach.CoachId;
                debater.SchoolId = currentCoach.SchoolId;
                _context.Add(debater);
                await _context.SaveChangesAsync();

                return(RedirectToAction("ManageTeam", "Coaches"));
            }
            return(View(debater));
        }
Example #10
0
 int GetJudgeVsSpeaker(Debater d, DebaterWidget dw)
 {
     if (d.ConflictsWith(dw.Debater) || dw.Debater.ConflictsWith(d))
     {
         return(-1);
     }
     else
     {
         int n = 0;
         MyDictionary <string, int> vr1 = d.VisitedRooms;
         MyDictionary <string, int> vr2 = dw.Debater.VisitedRooms;
         // we are only interested in the intersection of roundNames
         foreach (KVP <string, int> kvp1 in vr1.Store)
         {
             // skip if this room is in the round...
             if (roomData.RoundName == kvp1.Key)
             {
                 continue;
             }
             // skip if debater isn't in any room
             if (kvp1.Val < 0)
             {
                 continue;
             }
             KVP <string, int> kvp2;
             if (vr2.GetKVP(kvp1.Key, out kvp2))
             {
                 // skip if debater isn't in any room
                 if (kvp2.Val < 0)
                 {
                     continue;
                 }
                 // same roomIndex?
                 if (kvp1.Val == kvp2.Val)
                 {
                     n++;
                 }
             }
         }
         return(n);
     }
 }
Example #11
0
        public IActionResult FormTeam([Bind("IndividualTeamId,FirstSpeaker,SecondSpeaker,FirstSpeakerId,SecondSpeakerId,SingleTournamentWins,SingleTournamentLosses,SingleTournamentSpeakerPoints,CumulativeAnnualWins,CumulativeAnnualLosses,CumulativeAnuualEliminationRoundWins,AnnualEliminationRoundAppearances,TournamentAffirmativeRounds,TournamentNegativeRounds,TocBids,CoachId,SchoolId")] IndividualTeam team)
        {
            var currentUserId = this.User.FindFirstValue(ClaimTypes.NameIdentifier).ToString();
            var currentCoach  = _context.Coach.FirstOrDefault(c => c.ApplicationUserId == currentUserId);
            var school        = _context.School.Where(s => s.SchoolId == currentCoach.SchoolId).Single();

            team.CoachId  = currentCoach.CoachId;
            team.SchoolId = currentCoach.SchoolId;
            Debater debater1 = new Debater();

            debater1          = team.FirstSpeaker;
            debater1.CoachId  = currentCoach.CoachId;
            debater1.SchoolId = currentCoach.SchoolId;
            Debater debater2 = new Debater();

            debater2          = team.SecondSpeaker;
            debater2.CoachId  = currentCoach.CoachId;
            debater2.SchoolId = currentCoach.SchoolId;
            _context.Add(debater1);
            _context.Add(debater2);
            _context.SaveChanges();
            debater1.PartnerId      = debater2.DebaterId;
            debater2.PartnerId      = debater1.DebaterId;
            team.IndividualTeamName = $"{school.Name} {debater1.LastName} & {debater2.LastName}";
            _context.Update(debater1);
            _context.Update(debater2);
            _context.SaveChanges();
            _context.Add(team);
            _context.SaveChanges();
            team.FirstSpeakerId       = debater1.DebaterId;
            team.SecondSpeakerId      = debater2.DebaterId;
            debater1.IndividualTeamId = team.IndividualTeamId;
            debater2.IndividualTeamId = team.IndividualTeamId;
            debater1.SpeakerPosition  = 1;
            debater2.SpeakerPosition  = 2;
            _context.Update(team);
            _context.Update(debater1);
            _context.Update(debater2);
            _context.SaveChanges();
            return(RedirectToAction("ManageTeam", "Coaches"));
        }
Example #12
0
        public IActionResult ViewPairings(int id)
        {
            Tournament            tournament    = _context.Tournament.FirstOrDefault(t => t.TournamentId == id);
            var                   currentUserId = this.User.FindFirstValue(ClaimTypes.NameIdentifier).ToString();
            Debater               debater       = _context.Debater.FirstOrDefault(d => d.ApplicationUserId == currentUserId);
            IndividualTeam        team          = _context.IndividualTeam.FirstOrDefault(i => i.IndividualTeamId == debater.IndividualTeamId);
            List <Pairing>        pairings      = _context.Pairing.Where(p => p.TournamentId == id && (p.AffirmativeTeamId == team.IndividualTeamId || p.NegativeTeamId == team.IndividualTeamId)).ToList();
            List <Judge>          judges        = new List <Judge>();
            List <IndividualTeam> affTeams      = new List <IndividualTeam>();
            List <IndividualTeam> negTeams      = new List <IndividualTeam>();
            List <Room>           rooms         = new List <Room>();
            List <Round>          rounds        = new List <Round>();

            foreach (var pair in pairings)
            {
                Judge judge = _context.Judge.FirstOrDefault(j => j.JudgeId == pair.JudgeId);
                judges.Add(judge);
                IndividualTeam affTeam = _context.IndividualTeam.FirstOrDefault(i => i.IndividualTeamId == pair.AffirmativeTeamId);
                affTeams.Add(affTeam);
                IndividualTeam negTeam = _context.IndividualTeam.FirstOrDefault(i => i.IndividualTeamId == pair.NegativeTeamId);
                negTeams.Add(negTeam);
                Room room = _context.Room.FirstOrDefault(r => r.RoomId == pair.RoomId);
                rooms.Add(room);
                Round round = _context.Round.FirstOrDefault(r => r.RoundId == pair.RoundId);
                rounds.Add(round);
            }

            PairingsTabulationViewModel data = new PairingsTabulationViewModel()
            {
                Tournament       = tournament,
                Rounds           = rounds,
                Rooms            = rooms,
                AffirmativeTeams = affTeams,
                NegativeTeams    = negTeams,
                Judges           = judges,
                Debater          = debater,
            };

            return(View(data));
        }
Example #13
0
        public IActionResult CompleteSpeakerAwards(int id)
        {
            List <IndividualTeam> teams    = GetTeams(id);
            List <Debater>        debaters = new List <Debater>();

            foreach (var team in teams)
            {
                Debater debater1 = _context.Debater.FirstOrDefault(d => d.DebaterId == team.FirstSpeakerId);
                Debater debater2 = _context.Debater.FirstOrDefault(d => d.DebaterId == team.SecondSpeakerId);
                debaters.Add(debater1);
                debaters.Add(debater2);
            }
            foreach (var debater in debaters)
            {
                int numberOfTournaments = _context.TeamEntry.Where(t => t.IndividualTeamId == debater.IndividualTeamId).ToList().Count();
                debater.AnnualAverageSpeakerPoints        = (((debater.AnnualAverageSpeakerPoints * (numberOfTournaments - 1)) + debater.IndividualTournamentSpeakerPoints) / numberOfTournaments);
                debater.IndividualTournamentSpeakerPoints = 0;
                _context.Update(debater);
                _context.SaveChanges();
            }
            return(View());
        }
Example #14
0
 public List <Debater> SpeakerAwardsList(int id, List <Round> roundsInOrder)
 {
     if (roundsInOrder[0].RoundNumber == 4)
     {
         Tournament            tournament    = _context.Tournament.FirstOrDefault(t => t.TournamentId == id);
         List <IndividualTeam> teams         = GetTeams(id);
         List <Debater>        debaters      = new List <Debater>();
         List <Debater>        speakerAwards = new List <Debater>();
         List <Debater>        emptyList     = new List <Debater>();
         int speakerAwardThreshold           = 10;
         foreach (var team in teams)
         {
             Debater debater1 = _context.Debater.FirstOrDefault(d => d.DebaterId == team.FirstSpeakerId);
             Debater debater2 = _context.Debater.FirstOrDefault(d => d.DebaterId == team.SecondSpeakerId);
             debaters.Add(debater1);
             debaters.Add(debater2);
         }
         List <Debater> speakerRankings = debaters.OrderByDescending(d => d.IndividualTournamentSpeakerPoints).ToList();
         for (int i = 0; i < speakerAwardThreshold; i++)
         {
             speakerAwards.Add(speakerRankings[i]);
         }
         if (speakerAwards[0].IndividualTournamentSpeakerPoints == 0)
         {
             return(emptyList);
         }
         else
         {
             return(speakerAwards);
         }
     }
     else
     {
         List <Debater> fakeList = new List <Debater>();
         return(fakeList);
     }
 }
Example #15
0
        protected virtual void OnBtnImportCSVClicked(object sender, System.EventArgs e)
        {
            if (cbOverwrite.Active)
            {
                if (MiscHelpers.AskYesNo(this,
                                         "This clears all " +
                                         "entered Data for " +
                                         "overwritten Debaters. " +
                                         "Continue?")
                    == ResponseType.No)
                {
                    return;
                }
            }
            // make a backup before!
            Tournament.I.Save();
            // start import
            List <Debater> debaters = Tournament.I.Debaters;
            int            line     = 0;

            try {
                CsvReader csv = new CsvReader(new StreamReader(labelFile.Text),
                                              cbHasHeaders.Active, ',', '"', '\\', '#',
                                              ValueTrimmingOptions.All);

                int dups = 0;
                int ok   = 0;
                while (csv.ReadNextRecord())
                {
                    line++;
                    EditableDebater d = new EditableDebater();

                    d.Name = new Name(csv[sbFirstName.ValueAsInt], csv[sbLastName.ValueAsInt]);

                    // Club
                    try {
                        if (cbCity.Active)
                        {
                            d.Club = new Club(csv[sbClub.ValueAsInt], csv[sbCity.ValueAsInt]);
                        }
                        else
                        {
                            d.Club = new Club(csv[sbClub.ValueAsInt]);
                        }
                    }
                    catch {
                        d.Club = new Club("None");
                        d.BlackList.RemoveClub("None");
                    }

                    // Age or from Birthday
                    try {
                        if (cbAge.Active)
                        {
                            d.Age = uint.Parse(csv [sbAge.ValueAsInt]);
                        }

                        if (cbBirthday.Active)
                        {
                            DateTime bday = DateTime.ParseExact(csv[sbBirthday.ValueAsInt],
                                                                entryBdayFormat.Text,
                                                                null);
                            DateTime now = DateTime.Today;
                            int      age = now.Year - bday.Year;
                            if (bday > now.AddYears(-age))
                            {
                                age--;
                            }
                            d.Age = (uint)age;
                        }
                    }
                    catch {}

                    // Role
                    if (cbRole.Active)
                    {
                        if (rbTeamMember.Active)
                        {
                            d.Role = OPDtabData.Role.Parse(csv [sbRole.ValueAsInt]);
                        }
                        else if (rbJudge.Active)
                        {
                            int judgeQuality = 0;
                            try {
                                judgeQuality = (int)uint.Parse(csv[sbRole.ValueAsInt]);
                            }
                            catch {}
                            d.Role.JudgeQuality = judgeQuality;
                        }
                    }

                    // ExtraInfo
                    d.ExtraInfo = entryExtraInfoDefault.Text;
                    if (cbExtraInfo.Active)
                    {
                        d.ExtraInfo = csv[sbExtraInfo.ValueAsInt] == "" ?
                                      entryExtraInfoDefault.Text : csv[sbExtraInfo.ValueAsInt];
                    }

                    // BlackList
                    if (cbBlackList.Active)
                    {
                        d.BlackList = DebaterPattern.Parse(csv[sbBlackList.ValueAsInt]);
                    }


                    // save it
                    int i = debaters.FindLastIndex(delegate(Debater de) {
                        return(de.Equals(d));
                    });

                    if (i < 0)
                    {
                        debaters.Add(new Debater(d));
                        ok++;
                    }
                    else
                    {
                        Console.WriteLine("Duplicate: " + d + ", " + debaters[i]);
                        dups++;
                        if (cbOverwrite.Active)
                        {
                            debaters[i] = new Debater(d);
                            ok++;
                        }
                    }
                }

                string action = cbOverwrite.Active ? "overwritten" : "discarded";
                MiscHelpers.ShowMessage(this, "Imported " + ok + ", " + action + " " + dups + " duplicates.",
                                        MessageType.Info);
            }
            catch (Exception ex) {
                MiscHelpers.ShowMessage(this, "Error encountered in line " + line.ToString() + ": " + ex.Message,
                                        MessageType.Error);
            }
        }
Example #16
0
 public EditableDebater(Debater d) : base(d)
 {
 }
Example #17
0
        void UpdateGuiSection(string section, int i, object data)
        {
            Container c = (Container)GetField("c" + section);

            if (data == null)
            {
                SetDummyLabel(c, section);
            }
            else if (data is List <RoundDebater> )
            {
                // Judges or FreeSpeakers (variable number...)
                MiscHelpers.ClearContainer(c);
                List <RoundDebater> list = (List <RoundDebater>)data;
                if (list.Count == 0)
                {
                    SetDummyLabel(c, section);
                }
                else
                {
                    for (int j = 0; j < list.Count; j++)
                    {
                        UpdateGuiSection(section, j, list[j]);
                    }
                    // append label for adding by D&D
                    if (small)
                    {
                        if (section == "Judges")
                        {
                            SetDummyLabel(c, section, roomData.Judges.Count.ToString());
                        }
                        else if (section == "FreeSpeakers" && list.Count < 3)
                        {
                            SetDummyLabel(c, section, "F");
                        }
                    }
                    else if (section == "Judges" || list.Count < 3)
                    {
                        SetDummyLabel(c, section, "Drag here to add");
                    }
                }
            }
            else
            {
                IDragDropWidget w = null;

                if (data is TeamData)
                {
                    if (small)
                    {
                        w = Team.Small((TeamData)data);
                    }
                    else
                    {
                        w = new Team((TeamData)data, null);
                    }
                }
                else if (data is RoundDebater)
                {
                    if (small)
                    {
                        w = DebaterWidget.Small((RoundDebater)data, false);
                    }
                    else
                    {
                        w = new DebaterWidget((RoundDebater)data);
                    }
                }
                else
                {
                    throw new NotImplementedException("Don't know how to create widget for data");
                }

                // tell Debater the room for visitedRooms list..
                w.SetRoom(roomData.RoundName, roomData);

                w.SetupDragDropSource(section, data);
                w.SetDataTrigger += delegate(Widget sender, object data_) {
                    SetItem(section, i, data_);
                };

                // Add to container after source, but before Dest
                Widget wi = (Widget)w;
                MiscHelpers.AddToContainer(c, wi, small);

                // Drag drop DestSet, needs Container for scrolling support...
                DragDropHelpers.DestSet(wi,
                                        DestDefaults.All,
                                        DragDropHelpers.TgtFromString(section),
                                        Gdk.DragAction.Move);

                wi.DragDataReceived += delegate(object o, DragDataReceivedArgs args) {
                    object data_ =
                        DragDropHelpers.Deserialize(args.SelectionData);
                    // save data here
                    SetItem(section, i, data_);
                    // delete data there
                    MyButton b = (MyButton)Drag.GetSourceWidget(args.Context);
                    b.Owner.SetData(data);
                };
            }
            // show judge quality by icons
            if (section == "Judges" && !small)
            {
                int    nStars     = 0;
                double sumAvgSpkr = 0.0;
                double sumAvgTeam = 0.0;
                int    nAvgSpkr   = 0;
                int    nAvgTeam   = 0;

                foreach (RoundDebater rd in roomData.Judges)
                {
                    Debater d = Tournament.I.FindDebater(rd);
                    if (d == null)
                    {
                        continue;
                    }
                    nStars += d.Role.JudgeQuality;
                    if (!double.IsNaN(d.StatsAvg[0]))
                    {
                        sumAvgSpkr += d.StatsAvg[0];
                        nAvgSpkr++;
                    }
                    if (!double.IsNaN(d.StatsAvg[2]))
                    {
                        sumAvgTeam += d.StatsAvg[2];
                        nAvgTeam++;
                    }
                }

                lblJudgeStats.Markup = "JudgeStats: " +
                                       JudgeStatsToMarkup(sumAvgSpkr, nAvgSpkr, 2) + " " +
                                       JudgeStatsToMarkup(sumAvgTeam, nAvgTeam, 5);


                MiscHelpers.ClearTable(tableJudgeStars);
                tableJudgeStars.NRows = (uint)nStars / 5 + 1;

                for (int j = 0; j < nStars; j++)
                {
                    uint col = (uint)j % 5;
                    uint row = (uint)j / 5;

                    tableJudgeStars.Attach(new Image(MiscHelpers.LoadIcon("face-smile")),
                                           col, col + 1,
                                           row, row + 1,
                                           AttachOptions.Shrink, AttachOptions.Shrink,
                                           0, 0);
                }
                if (nStars == 0)
                {
                    tableJudgeStars.HideAll();
                }
                else
                {
                    tableJudgeStars.ShowAll();
                }
            }
        }
Example #18
0
        public IActionResult ViewBallot(JudgesBallotViewModel data)
        {
            Pairing        pairing          = _context.Pairing.Where(p => p.JudgeId == data.Ballot.JudgeId && p.RoundId == data.Ballot.RoundId).Single();
            IndividualTeam affTeam          = _context.IndividualTeam.FirstOrDefault(i => i.IndividualTeamId == pairing.AffirmativeTeamId);
            IndividualTeam negTeam          = _context.IndividualTeam.FirstOrDefault(i => i.IndividualTeamId == pairing.NegativeTeamId);
            Debater        firstAffSpeaker  = _context.Debater.FirstOrDefault(d => d.IndividualTeamId == affTeam.IndividualTeamId && d.SpeakerPosition == 1);
            Debater        secondAffSpeaker = _context.Debater.FirstOrDefault(d => d.IndividualTeamId == affTeam.IndividualTeamId && d.SpeakerPosition == 2);
            Debater        firstNegSpeaker  = _context.Debater.FirstOrDefault(d => d.IndividualTeamId == negTeam.IndividualTeamId && d.SpeakerPosition == 1);
            Debater        secondNegSpeaker = _context.Debater.FirstOrDefault(d => d.IndividualTeamId == negTeam.IndividualTeamId && d.SpeakerPosition == 2);
            Ballot         ballot           = data.Ballot;
            Round          round            = _context.Round.Where(r => r.RoundId == ballot.RoundId).Single();
            var            winnerId         = int.Parse(data.Winner);
            var            loserId          = int.Parse(data.Loser);
            IndividualTeam winningTeam      = _context.IndividualTeam.FirstOrDefault(i => i.IndividualTeamId == winnerId);
            IndividualTeam losingTeam       = _context.IndividualTeam.FirstOrDefault(i => i.IndividualTeamId == loserId);

            firstAffSpeaker.IndividualTournamentSpeakerPoints  += data.Ballot.FirstAffSpeakerPoints;
            secondAffSpeaker.IndividualTournamentSpeakerPoints += data.Ballot.SecondAffSpeakerPoints;
            firstNegSpeaker.IndividualTournamentSpeakerPoints  += data.Ballot.FirstNegSpeakerPoints;
            secondNegSpeaker.IndividualTournamentSpeakerPoints += data.Ballot.SecondNegSpeakerPoints;
            affTeam.SingleTournamentSpeakerPoints += (data.Ballot.FirstAffSpeakerPoints + data.Ballot.SecondAffSpeakerPoints);
            negTeam.SingleTournamentSpeakerPoints += (data.Ballot.FirstNegSpeakerPoints + data.Ballot.SecondNegSpeakerPoints);
            ballot.WinnerId  = winnerId;
            pairing.WinnerId = winnerId;
            if (round.RoundNumber > 4)
            {
                winningTeam.CumulativeAnnualElminationRoundWins++;
                losingTeam.SingleTournamentSpeakerPoints = 0;
                losingTeam.SingleTournamentWins          = 0;
                losingTeam.SingleTournamentLosses        = 0;
                losingTeam.TournamentAffirmativeRounds   = 0;
                losingTeam.TournamentNegativeRounds      = 0;
            }
            if (round.RoundNumber == 7)
            {
                TournamentResults result = _context.TournamentResults.Where(t => t.TournamentId == pairing.TournamentId && t.IndividualTeamId == winningTeam.IndividualTeamId).Single();
                result.EliminationRoundResult = "winner";
                _context.Update(result);
                winningTeam.CumulativeAnnualElminationRoundWins++;
                winningTeam.SingleTournamentSpeakerPoints = 0;
                winningTeam.SingleTournamentWins          = 0;
                winningTeam.SingleTournamentLosses        = 0;
                winningTeam.TournamentAffirmativeRounds   = 0;
                winningTeam.TournamentNegativeRounds      = 0;
                losingTeam.SingleTournamentSpeakerPoints  = 0;
                losingTeam.SingleTournamentWins           = 0;
                losingTeam.SingleTournamentLosses         = 0;
                losingTeam.TournamentAffirmativeRounds    = 0;
                losingTeam.TournamentNegativeRounds       = 0;
            }
            if (round.RoundNumber <= 4)
            {
                winningTeam.SingleTournamentWins++;
                losingTeam.SingleTournamentLosses++;
            }
            winningTeam.CumulativeAnnualWins++;
            losingTeam.CumulativeAnnualLosses++;
            ballot.BallotTurnedIn = true;
            _context.Update(ballot);
            _context.Update(pairing);
            _context.Update(winningTeam);
            _context.Update(losingTeam);
            _context.Update(firstAffSpeaker);
            _context.Update(secondAffSpeaker);
            _context.Update(firstNegSpeaker);
            _context.Update(secondNegSpeaker);
            _context.SaveChanges();
            return(RedirectToAction("BallotSubmission", "Judges"));
        }
Example #19
0
 public void Set(Debater debater)
 {
     set(debater, prop);
 }
Example #20
0
        // GET: Debaters/Create
        public IActionResult Create()
        {
            Debater debater = new Debater();

            return(View(debater));
        }