Beispiel #1
0
 // Complex Jumps for judge overview
 public static List <EventJumpModel> LoadEventJumps(EventJumpModel eventjump, string query)
 {
     using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
     {
         var output = cnn.Query <EventJumpModel>(query, eventjump);
         return(output.ToList());
     }
 }
        public void FinalScore(int jumpID, int groupnr, char style, float height, float dd)
        {
            Console.WriteLine("Finalscore - jump ID: " + jumpID);

            string     query = "update jump set finalscore = @finalscore where jumpID=@jumpID";
            ScoreModel obj   = new ScoreModel();

            obj.jumpID = jumpID;
            int count = Int32.Parse(SqliteDataAccess.SingleObjectString(obj, "score", "jumpID", "count(jumpID)"));

            Console.WriteLine("Score count: " + count);

            if (count == 3)
            {
                Console.WriteLine("All scores are submitted");
                //fetch all three scores:
                //discard highest and lowest
                //muliply by 3
                //multiply by (degree of difficulty)

                //Fetch degree of difficulty
                Console.WriteLine("degree of difficulty: " + dd);

                //Fetch all judge scores
                string         query_all_scores = "select * from score where jumpID = @jumpID";
                EventJumpModel jumpscores       = new EventJumpModel();
                jumpscores.jumpID = jumpID;
                scoreList         = SqliteDataAccess.LoadManyObjects(jumpscores, query_all_scores);
                foreach (var c in scoreList)
                {
                    Console.WriteLine("C: " + c.score);
                }

                int i, j;
                //bubbelsort the three scores
                for (i = 0; i < 2; i++)
                {
                    for (j = 0; j < 2 - i; j++)
                    {
                        if (scoreList[j].score > scoreList[j + 1].score)
                        {
                            var temp = scoreList[j + 1];
                            scoreList[j + 1] = scoreList[i];
                            scoreList[j]     = temp;
                        }
                    }
                }
                var median_score = scoreList[1].score;
                Console.WriteLine("Median score: " + median_score);

                //Calcualtes finalscore
                var final_score = (median_score * 3) * dd;
                Console.WriteLine("Final score: " + final_score);
                final_score.ToString("0.00");
                Console.WriteLine("fscore: " + final_score);
                EventJumpModel finalScore = new EventJumpModel();
                finalScore.finalscore = final_score;
                finalScore.jumpID     = jumpID;


                var query_final = "update jump set finalscore = @finalscore where jumpID=@jumpID";

                SqliteDataAccess.SaveSingleObject(finalScore, query_final);
            }
            else
            {
                //skip
            }
        }
Beispiel #3
0
        //gets the current/upcoming event for the judge
        public ActionResult GetEvent()
        {
            string query = "select j.eventID, j.competitorID, u.fname," +
                           "  u.lname,  j.jumpnr, j.jumptype, us.fname as JudgeFirstName ," +
                           " us.lname as JudgeLastName, s.score, j.finalscore " +
                           "from jump as j " +
                           "left join score as s on j.jumpID = s.jumpID " +
                           "left join competitor as c on c.competitorID = j.competitorID " +
                           "left join user as u on u.userID = c.userID " +
                           "left join judge as ju on ju.judgeID = s.judgeID " +
                           "left join user as us on us.userID = ju.userID " +
                           "where j.eventID = @eventID " +
                           "order by j.competitorID and j.jumpnr";


            EventJumpModel eventjump = new EventJumpModel();

            eventjump.userID = (int)HttpContext.Session.GetInt32("UserID");
            Console.WriteLine("userID: " + eventjump.userID);
            StringBuilder jumpListHtml = new StringBuilder("<table id=\"jumpTbl\">" +
                                                           "<tr><th>Event Name</th><th>Competitor ID</th>" +
                                                           "<th>First Name</th><th>Last Name</th><th>Jump nr</th><th>Jump Type</th>" +
                                                           "<th>Judge First Name</th><th>Judge Last Name</th><th>Score</th><th>Final Score</th></tr>");


            string query_original = "select j.jumpID, j.eventID, j.competitorID," +
                                    " u.fname,  u.lname,  j.jumpnr, s.judgeID, s.score, j.finalscore" +
                                    " from jump as j inner join score as s on j.jumpID = s.jumpID " +
                                    "inner join competitor as c on c.competitorID = j.competitorID " +
                                    "inner join user as u on u.userID = c.userID " +
                                    "where j.eventID = @eventID group by j.jumpID, s.judgeID";

            string query_upcoming_event = "SELECT e.eventID from event as e " +
                                          "inner join eventjudge as ej on ej.eventID = e.eventID " +
                                          "inner join judge as j on j.judgeID = ej.judgeID " +
                                          "inner join user as u on u.userID = j.userID " +
                                          "where u.userID=@userID and startdate>=date('now') " +
                                          "order by startdate " +
                                          "asc limit 1";

            eventjump = SqliteDataAccess.SingleObject(eventjump, query_upcoming_event);

            if (eventjump == null)
            {
                return(RedirectToAction("Scoring", "Home"));
            }
            Console.WriteLine("event: " + eventjump.eventID);

            jumpObjList = SqliteDataAccess.LoadEventJumps(eventjump, query);
            Console.WriteLine("list: " + jumpObjList);

            int i = 1;

            foreach (var jump in jumpObjList)
            {
                jumpListHtml.Append("<tr id=" + i + "><td>");
                jumpListHtml.Append(eventjump.eventID);
                jumpListHtml.Append("</td><td>");
                jumpListHtml.Append(jump.competitorID);
                jumpListHtml.Append("</td><td>");
                jumpListHtml.Append(jump.fname);
                jumpListHtml.Append("</td><td>");
                jumpListHtml.Append(jump.lname);
                jumpListHtml.Append("</td><td>");
                jumpListHtml.Append(jump.jumpnr);
                jumpListHtml.Append("</td><td>");
                jumpListHtml.Append(jump.jumptype);
                jumpListHtml.Append("</td><td>");
                jumpListHtml.Append(jump.JudgeFirstName);
                jumpListHtml.Append("</td><td>");
                jumpListHtml.Append(jump.JudgeLastName);
                jumpListHtml.Append("</td><td>");
                jumpListHtml.Append(jump.score);
                jumpListHtml.Append("</td><td>");
                jumpListHtml.Append(jump.finalscore);
                jumpListHtml.Append("</td></tr>");
            }

            jumpListHtml.Append("</table>");


            TempData["eventjumps"] = jumpListHtml.ToString();


            return(RedirectToAction("Scoring", "Home"));
        }