示例#1
0
        public async Task <DealContainer> GetDealContainerAsync(string token)
        {
            DealContainer container = null;

            HttpClient client = this.GetHttpClientToken(token);

            HttpResponseMessage response = await client.GetAsync(_serverUrl + "deals/");

            var content = await response.Content.ReadAsStringAsync();

            switch (response.StatusCode)
            {
            case System.Net.HttpStatusCode.OK:

                Debug.WriteLine(content);
                container = JsonConvert.DeserializeObject <DealContainer>(content);
                break;

            case System.Net.HttpStatusCode.Unauthorized:
                throw new AuthorizationException("Unknown token");

            default:
                throw new Exception(content);
            }
            return(container);
        }
示例#2
0
        public async Task <DealContainer> GetDealContainerWithRetryAsync(bool retry = true)
        {
            DealContainer container = null;

            try
            {
                container = await GetDealContainerAsync(_token);
            }
            catch (AuthorizationException)
            {
                if (retry)
                {
                    await RenewAuthToken();

                    container = await GetDealContainerAsync(_token);
                }
                else
                {
                    throw;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(container);
        }
 public Deal UpdateDeal(Deal deal, int dealId)
 {
     return(DealContainer.UpdateDeal(deal, dealId));
 }
 public DealStatus UpdateDealStatus(int dealId, DealStatus status)
 {
     DealContainer.UpdateStatus(dealId, status);
     return(status);
 }
 public void RemoveDeal(int dealId)
 {
     DealContainer.RescueDeal(dealId);
 }
 public Deal GetDealById(int dealId)
 {
     return(DealContainer.GetDealById(dealId));
 }
 public IEnumerable <Deal> GetAllDeals()
 {
     return(DealContainer.GetAllDeals());
 }
 public Deal DeliveryDeal(int dealId)
 {
     return(DealContainer.DeliveryDeal(dealId));
 }
 public Deal AddDeal(Deal deal)
 {
     return(DealContainer.AddDeal(deal));
 }