Exemplo n.º 1
0
        public string Add(vCard vcard)
        {
            string vCardId = null;

            vCardId = this.GenerateVCardId();

            Dictionary<string, string> results = this.Query(this.serverUrl + vCardId, "PUT", vcard.ToString(), "text/vcard");

            if (results.ContainsKey("status"))
            {
                string status = results["status"];

                if (status.Equals("200") || status.Equals("207") || status.Equals("204") || status.Equals("201") || status.ToLower().Equals("ok"))
                {
                    return vCardId;
                }
                else
                {
                    throw new HTTPException("Whoops something went wrong! The server returned a status code of: " + status);
                }
            }
            else
            {
                throw new HTTPException("No status code returned from HTTP Request");
            }
        }
Exemplo n.º 2
0
        public bool Update(vCard vcard, string id)
        {
            Dictionary<string, string> results = this.Query(this.serverUrl + id, "PUT", vcard.ToString(), "text/vcard");

            if (results.ContainsKey("status"))
            {
                string status = results["status"];

                if (status.Equals("200") || status.Equals("207") || status.Equals("204") || status.Equals("201") || status.ToLower().Equals("ok"))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }

            return false;
        }