Пример #1
0
        internal int SavePortFolio(CompanyPortFolioEntity portfolioEntity)
        {
            using (_httpClient = new HttpClient())
            {
                string WebAPIURL   = System.Configuration.ConfigurationManager.AppSettings["WebAPIURL"].ToString();
                string apiMethod   = "SaveUpdateCompanyPortFolio";
                string completeURL = WebAPIURL + apiMethod + '/';

                StringContent httpContent = new StringContent(JsonConvert.SerializeObject(portfolioEntity), Encoding.UTF8, "application/json");

                HttpResponseMessage response = _httpClient.PostAsync(completeURL, httpContent).Result;
                if (response.IsSuccessStatusCode)
                {
                    return(Convert.ToInt32(response.Content.ReadAsStringAsync().Result));
                }
                else
                {
                    return(0);
                }
            }
        }
Пример #2
0
        internal CompanyPortFolioEntity GetPortfolioInfoByID(CompanyPortFolioEntity PortFolioFilter)
        {
            using (_httpClient = new HttpClient())
            {
                string        WebAPIURL   = System.Configuration.ConfigurationManager.AppSettings["WebAPIURL"].ToString();
                string        apiMethod   = "GetPortfolioInfoByID";
                string        completeURL = WebAPIURL + apiMethod;
                StringContent httpContent = new StringContent(JsonConvert.SerializeObject(PortFolioFilter), Encoding.UTF8, "application/json");

                HttpResponseMessage    response     = _httpClient.PostAsync(completeURL, httpContent).Result;
                CompanyPortFolioEntity PortFolioObj = new CompanyPortFolioEntity();
                if (response.IsSuccessStatusCode)
                {
                    PortFolioObj = JsonConvert.DeserializeObject <CompanyPortFolioEntity>(response.Content.ReadAsStringAsync().Result);
                    return(PortFolioObj);
                }
                else
                {
                    return(PortFolioObj);
                }
            }
        }