Ejemplo n.º 1
0
        public string Get_matches(string endpoint, string timestamp)
        {
            bool endpoint_exist = false;

            endpoint_exist = Other_methods.The_existence_check(endpoint_exist, endpoint, timestamp);
            if (endpoint_exist)
            {
                Models.Matches matches1         = new Models.Matches();
                string[]       string_parametrs = new string[2];
                matches1.map         = WorkSQL.Select_matche_string_parametrs(endpoint, timestamp)[0][0];
                matches1.gameMode    = WorkSQL.Select_matche_string_parametrs(endpoint, timestamp)[0][1];
                matches1.fragLimit   = WorkSQL.Select_matche_int_parametrs(endpoint, timestamp)[0][1];
                matches1.timeLimit   = WorkSQL.Select_matche_int_parametrs(endpoint, timestamp)[0][0];
                matches1.timeElapsed = WorkSQL.Select_matche_double_parametr(endpoint, timestamp)[0];
                matches1.scoreboard  = new List <Models.class_scoreboard>();
                foreach (var a in WorkSQL.Select_scoreboard_name(endpoint, timestamp))
                {
                    matches1.scoreboard.Add(new Models.class_scoreboard()
                    {
                        name = a, frags = WorkSQL.Select_scoreboard_int_parametrs(endpoint, timestamp, a)[0][0], kills = WorkSQL.Select_scoreboard_int_parametrs(endpoint, timestamp, a)[0][1], deaths = WorkSQL.Select_scoreboard_int_parametrs(endpoint, timestamp, a)[0][2]
                    });
                }

                string serilized = JsonConvert.SerializeObject(matches1);
                return(serilized);
            }
            else
            {
                return("404 Not Found");
            }
        }
Ejemplo n.º 2
0
        public HttpResponseMessage Put_matches([FromBody] JToken jsonbody, string endpoint, string timestamp)
        {
            Models.Matches      putMatches = JsonConvert.DeserializeObject <Models.Matches>(jsonbody.ToString());
            HttpResponseMessage message    = Request.CreateResponse(HttpStatusCode.OK);
            bool endpoint_exist            = false;

            endpoint_exist = Other_methods.The_existence_check(endpoint_exist, endpoint);
            if (!endpoint_exist)
            {
                string        output  = "400 Not Found";
                StringContent content = new StringContent(output, Encoding.UTF8, "application/json");
                message         = Request.CreateResponse(HttpStatusCode.NotFound);
                message.Content = content;
            }
            else
            {
                string        output  = "Match add";
                StringContent content = new StringContent(output, Encoding.UTF8, "application/json");
                message         = Request.CreateResponse(HttpStatusCode.OK);
                message.Content = content;
                WorkSQL.Add_match(endpoint, timestamp, putMatches.map, putMatches.gameMode, putMatches.fragLimit, putMatches.timeLimit, putMatches.timeElapsed);
                int g = 0;
                while (g < putMatches.scoreboard.Count)
                {
                    WorkSQL.Add_scoreboard(endpoint, timestamp, putMatches.scoreboard[g].name, putMatches.scoreboard[g].frags, putMatches.scoreboard[g].kills, putMatches.scoreboard[g].deaths);
                    g++;
                }
            }
            return(message);
        }