Exemple #1
0
        public void Put_info([ModelBinder] Models.Info putInfo, string endpoint)
        {
            HttpResponseMessage message = Request.CreateResponse(HttpStatusCode.OK);
            bool EndpointExist          = false;

            EndpointExist = Other_methods.The_existence_check(EndpointExist, endpoint);
            if (EndpointExist)
            {
                WorkSQL.UPDATE_info(endpoint, putInfo.name);
                WorkSQL.DELETE_gameModes(endpoint);
                int i = 0;
                while (i < putInfo.gameModes.Length)
                {
                    WorkSQL.Add_advertise_gameModes(endpoint, putInfo.gameModes[i]);
                    i++;
                }
            }
            else
            {
                WorkSQL.Add_advertise_info(endpoint, putInfo.name);
                int j = 0;
                while (j < putInfo.gameModes.Length)
                {
                    WorkSQL.Add_advertise_gameModes(endpoint, putInfo.gameModes[j]);
                    j++;
                }
            }
        }
Exemple #2
0
        public string Get_endpoint(string endpoint)
        {
            bool EndpointExist = false;

            EndpointExist = Other_methods.The_existence_check(EndpointExist, endpoint);
            if (EndpointExist)
            {
                Models.Info   info1     = new Models.Info();
                List <string> gameModes = WorkSQL.Select_gameModes(endpoint);
                int           i         = 0;
                info1.gameModes = new string[gameModes.Count];
                foreach (var a in gameModes)
                {
                    info1.gameModes[i] = a;
                    i++;
                }
                info1.name = WorkSQL.Select_name(endpoint)[0];
                string serilized = JsonConvert.SerializeObject(info1);
                return(serilized);
            }
            else
            {
                return("404 Not Found");
            }
        }
Exemple #3
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");
            }
        }
Exemple #4
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);
        }