Esempio n. 1
0
 private void LoadProducts()
 {
     try
     {
         if (Token == null)
         {
             throw new InvalidOperationException("Login first");
         }
         //Get last remote modification
         HttpClient client = new HttpClient();
         client.BaseAddress = new Uri(baseUrl);
         client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token.access_token);
         GetProductsFromApi();
         productView.Products = originalProducts;
     }
     catch (Exception ex)
     {
         StackTrace st = new StackTrace();
         StackFrame sf = st.GetFrame(0);
         MethodBase currentMethodName = sf.GetMethod();
         Guid       errorId           = Guid.NewGuid();
         //Log error here
         productView.HandleException(ex, currentMethodName.Name, errorId);
     }
 }