public static async Task addMatch(string name, DateTime date, DateTime start, DateTime end,
                                          int maxPlayers, string field, string[] invited = null)
        {
            using (HttpClient hc = new HttpClient())
            {
                hc.DefaultRequestHeaders.IfModifiedSince = new DateTimeOffset(DateTime.Now);
                MatchTmp            match = new MatchTmp();
                HttpResponseMessage msg;
                match.name       = name;
                match.startDate  = start.ToString("o").Split('+')[0];
                match.endDate    = end.ToString("o").Split('+')[0];
                match.maxPlayers = maxPlayers;
                match.field      = field;
                hc.DefaultRequestHeaders.Add("x-access-token", WeBallAPI.token);
                hc.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                Uri    connectionUri = new Uri(WeBallAPI.baseUri + "/matches/");
                string parsed        = "{ \"match\" :" + JsonConvert.SerializeObject(match) + "}";
                msg = await hc.PostAsync(connectionUri, new StringContent(parsed, Encoding.UTF8, "application/json"));

                System.Diagnostics.Debug.WriteLine("Sending: " + parsed);
                if (msg.IsSuccessStatusCode)
                {
                    string response = msg.Content.ReadAsStringAsync().Result;
                    System.Diagnostics.Debug.WriteLine("Matches created! Received: " + response);
                    success = true;
                    JToken parsedResponse = JObject.Parse(response);
                }
                else
                {
                    success = false;
                    System.Diagnostics.Debug.WriteLine("Error " + msg.StatusCode + " and " + msg.Content.ReadAsStringAsync().Result);
                }
            }
        }
        public static async Task updateMatch(Match match, int length)
        {
            try
            {
                using (HttpClient hc = new HttpClient())
                {
                    hc.DefaultRequestHeaders.Add("x-access-token", WeBallAPI.token);
                    var method = new HttpMethod("PATCH");
                    HttpResponseMessage msg;
                    var      keyValuePairs = new Dictionary <string, string>();
                    MatchTmp matchTmp      = new MatchTmp();
                    matchTmp.name       = match.name;
                    matchTmp.field      = match.field;
                    matchTmp.startDate  = match.startDate.ToString("o").Split('+')[0];
                    matchTmp.endDate    = match.startDate.AddHours(length).ToString("o").Split('+')[0];
                    matchTmp.maxPlayers = match.maxPlayers;
                    keyValuePairs.Add("match", JsonConvert.SerializeObject(matchTmp));
//                    keyValuePairs.Add("team", );
                    var content = new FormUrlEncodedContent(keyValuePairs);
                    var request = new HttpRequestMessage(method, WeBallAPI.baseUri + "/matches/" + match._id)
                    {
                        Content = content
                    };
                    msg = await hc.SendAsync(request);

                    if (msg.IsSuccessStatusCode)
                    {
                        MessageBoxResult result =
                            MessageBox.Show("Match modifié!",
                                            "OK",
                                            MessageBoxButton.OK);
                        success = true;
                    }
                    else
                    {
                        MessageBoxResult result =
                            MessageBox.Show("Erreur. Mauvaise horaire/durée? " + msg.Content.ReadAsStringAsync().Result,
                                            "Erreur",
                                            MessageBoxButton.OK);
                        success = false;
                    }
                }
            }
            catch (Exception e)
            {
                success = false;
                MessageBoxResult result =
                    MessageBox.Show("Erreur innatendue. Réessayez ultérieurement!",
                                    "Erreur",
                                    MessageBoxButton.OK);
            }
        }