Ejemplo n.º 1
0
        public ActionResult EventApplication(int ID, string button)
        {
            EventApplicationModel eventApplication = new EventApplicationModel();

            eventApplication.ID = ID;
            Console.WriteLine("id: " + eventApplication.ID);
            Console.WriteLine("btn: " + button);

            if (button == "refresh")
            {
                StringBuilder applicationListHtml = new StringBuilder("<table id=\"pplTbl\"><tr><th>ID</th><th>Event ID</th><th>Club ID</th><th>Club Name</th><th>Gender</th><th>Date</th></tr>");
                events = SqliteDataAccess.LoadEventApplication();

                int i = 1;

                foreach (var app in events)
                {
                    applicationListHtml.Append("<tr id=" + i + "><td>");
                    applicationListHtml.Append(app.ID);
                    applicationListHtml.Append("</td><td>");
                    applicationListHtml.Append(app.eventID);
                    applicationListHtml.Append("</td><td>");
                    applicationListHtml.Append(app.clubID);
                    applicationListHtml.Append("</td><td>");
                    applicationListHtml.Append(app.clubname);
                    applicationListHtml.Append("</td><td>");
                    applicationListHtml.Append(app.gender);
                    applicationListHtml.Append("</td><td>");
                    applicationListHtml.Append(app.startdate);
                    applicationListHtml.Append("</td></tr>");
                }

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

                Console.WriteLine(applicationListHtml);

                TempData["EventApps"] = applicationListHtml.ToString();
            }
            else if (button == "accept" && ID != 0)
            {
                eventApplication.eventID = SqliteDataAccess.SingleObjectString(eventApplication, "eventapplication", "ID", "eventID");
                eventApplication.clubID  = Int32.Parse(SqliteDataAccess.SingleObjectString(eventApplication, "eventapplication", "ID", "clubID"));

                Console.WriteLine("event id: " + eventApplication.eventID);
                Console.WriteLine("club id: " + eventApplication.clubID);
                SqliteDataAccess.ApproveEvent(eventApplication);
            }
            else if (button == "deny" && ID != 0)
            {
                SqliteDataAccess.DenyEvent(eventApplication);
            }
            else
            {
                Console.WriteLine("Shit went wrong!");
            }


            return(RedirectToAction("Managment", "Home"));
        }
Ejemplo n.º 2
0
        public ActionResult RoleApplication(int userIDField, string button)
        {
            Console.WriteLine("LoadRoleApplication triggered!");
            RoleApplicationModel applicant = new RoleApplicationModel();

            applicant.userID = userIDField;
            Console.WriteLine("ID: " + applicant.userID);
            Console.WriteLine("role: " + applicant.role);


            if (button == "refresh")
            {
                StringBuilder applicationListHtml = new StringBuilder("<table id=\"pplTbl\"><tr><th>User ID</th><th>First Name</th><th>Last Name</th><th>Role</th></tr>");
                applications = SqliteDataAccess.LoadRoleApplication();

                foreach (var app in applications)
                {
                    applicationListHtml.Append("<tr><td>");
                    applicationListHtml.Append(app.userID);
                    applicationListHtml.Append("</td><td>");
                    applicationListHtml.Append(app.fname);
                    applicationListHtml.Append("</td><td>");
                    applicationListHtml.Append(app.lname);
                    applicationListHtml.Append("</td><td>");
                    applicationListHtml.Append(app.role);
                    applicationListHtml.Append("</td></tr>");
                }

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

                Console.WriteLine(applicationListHtml);

                TempData["RoleApps"] = applicationListHtml.ToString();
            }
            else if (button == "accept" && userIDField != 0)
            {
                //Finds the requested role
                applicant.role = SqliteDataAccess.SingleObjectString(applicant, "roleapplication", "userID", "role");
                //Approves request
                SqliteDataAccess.ApproveRole(applicant);
            }
            else if (button == "deny" && userIDField != 0)
            {
                SqliteDataAccess.DenyRole(applicant);
            }
            else
            {
                Console.WriteLine("Shit went wrong!");
            }
            return(RedirectToAction("Managment", "Home"));
        }
Ejemplo n.º 3
0
        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
            }
        }