public Account getAccount(int AccountId)
 {
     try
     {
         Clients    client        = new Clients();
         HttpClient accountClient = client.AccountDetails();
         var        contentType   = new MediaTypeWithQualityHeaderValue("application/json");
         accountClient.DefaultRequestHeaders.Accept.Add(contentType);
         var response = accountClient.GetAsync("api/Account/getAccount/" + AccountId).Result;
         if (!response.IsSuccessStatusCode)
         {
             throw new ArgumentNullException("Unable to fetch the Account from  Account API ");
         }
         var result  = response.Content.ReadAsStringAsync().Result;
         var account = JsonConvert.DeserializeObject <Account>(result);
         return(account);
     }
     catch (ArgumentNullException e)
     {
         _log4net.Error(e.Message);
         throw e;
     }
     catch (Exception e)
     {
         _log4net.Error("Exception occured while getting Account details for account id-> " + AccountId);
         throw e;
     }
 }
        public TransactionStatus deposit(int AccountId, int amount)
        {
            TransactionStatus status = new TransactionStatus();

            try
            {
                Clients    obj           = new Clients();
                HttpClient accountClient = obj.AccountDetails();
                //var contentType = new MediaTypeWithQualityHeaderValue("application/json");
                //accountClient.DefaultRequestHeaders.Accept.Add(contentType);
                // var res= accountClient.PostAsJsonAsync("api/Account/deposit", new { AccountId = AccountId, amount = amount }).Result;
                StringContent       content  = new StringContent(JsonConvert.SerializeObject(new { AccountId = AccountId, amount = amount }), Encoding.UTF8, "application/json");
                HttpResponseMessage response = accountClient.PostAsync("api/Account/deposit", content).Result;
                if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError)
                {
                    throw new ArgumentNullException("Error in calling Account API to deposit money");
                }
                var result = response.Content.ReadAsStringAsync().Result;
                status = JsonConvert.DeserializeObject <TransactionStatus>(result);
            }
            catch (ArgumentNullException e)
            {
                _log4net.Error(e.Message);
                throw e;
            }
            catch (Exception e)
            {
                _log4net.Error("Not able to deposit in account with account id " + AccountId + " and amount " + amount);
                throw e;
            }

            return(status);
        }
        public TransactionStatus withdraw(int AccountId, int amount)
        {
            try
            {
                Clients    client        = new Clients();
                HttpClient AccountClinet = client.AccountDetails();
                var        contentType   = new MediaTypeWithQualityHeaderValue("application/json");
                AccountClinet.DefaultRequestHeaders.Accept.Add(contentType);
                StringContent content = new StringContent(JsonConvert.SerializeObject(new { AccountId = AccountId, amount = amount }), Encoding.UTF8, "application/json");

                HttpResponseMessage response = AccountClinet.PostAsync("api/Account/withdraw", content).Result;
                var result = response.Content.ReadAsStringAsync().Result;
                TransactionStatus status = JsonConvert.DeserializeObject <TransactionStatus>(result);
                return(status);
            }
            catch (Exception e)
            {
                _log4net.Error("unable to withdraw from account with account id " + AccountId + " and amount " + amount);
                throw e;
            }
        }