Exemplo n.º 1
0
 public void Delete(string sessionKey, IdentityModel identityModel)
 {
     //Send Payload
     var req = new WebClient();
     req.BaseAddress = endpoint + "/Remote/Account/Delete";
     req.Headers.Clear();
     req.Headers.Add("Accept", "application/json");
     req.Headers.Add(Headers.SessionKey, sessionKey);
     try
     {
         var request = req.UploadData(endpoint + "/Remote/Account/Delete", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(identityModel)));
         //Do nothing
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemplo n.º 2
0
        public void Delete(string sessionKey, IdentityModel identityModel)
        {
            //Send Payload
            var req = new HttpClient();
            req.BaseAddress = new Uri(endpoint + "/Remote/Account/Delete");
            req.DefaultRequestHeaders.Accept.Clear();
            req.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            req.DefaultRequestHeaders.Add(Headers.SessionKey, sessionKey);
            var request = req.PostAsJsonAsync(endpoint + "/Remote/Account/Delete", identityModel);
            if (request.Result.IsSuccessStatusCode)
            {

                //Do nothing
            }
            else
            {
                throw new Exception(request.Result.Content.ReadAsStringAsync().Result);
            }
        }
Exemplo n.º 3
0
 public AccountModel Read(string sessionKey, IdentityModel identityModel)
 {
     //Send Payload
     var req = new HttpClient();
     req.BaseAddress = new Uri(endpoint + "/Remote/Account/Read");
     req.DefaultRequestHeaders.Accept.Clear();
     req.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
     req.DefaultRequestHeaders.Add(Headers.SessionKey, sessionKey);
     var request = req.PostAsJsonAsync(endpoint + "/Remote/Account/Read", identityModel);
     if (request.Result.IsSuccessStatusCode)
     {
         var data = request.Result.Content.ReadAsStringAsync().Result;
         DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AccountModel));
         return (AccountModel)serializer.ReadObject(request.Result.Content.ReadAsStreamAsync().Result);
     }
     else
     {
         throw new Exception(request.Result.Content.ReadAsStringAsync().Result);
     }
 }