Ejemplo n.º 1
0
 public static bool LoadInvoices()
 {
     try
     {
         InvoicesList.Clear();
         using (var sr = new StreamReader(FilePath))
         {
             var deSerializer  = new XmlSerializer(typeof(ObservableCollection <Invoice>));
             var tmpCollection =
                 (ObservableCollection <Invoice>)deSerializer.Deserialize(sr);
             foreach (var item in tmpCollection)
             {
                 InvoicesList.Add(item);
             }
             return(true);
         }
     }
     catch (Exception ex)
     {
         if (ex is FileNotFoundException)
         {
             var sw = new StreamWriter(FilePath);
         }
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
 internal static InvoicesList getInvoiceList(HttpResponseMessage responce)
 {
     var invoiceList = new InvoicesList();
     var jsonObj = JsonConvert.DeserializeObject<Dictionary<string, object>>(responce.Content.ReadAsStringAsync().Result);
     if (jsonObj.ContainsKey("invoices"))
     {
         var invoicesArray = JsonConvert.DeserializeObject<List<object>>(jsonObj["invoices"].ToString());
         foreach(var invoiceObj in invoicesArray)
         {
             var invoice = new Invoice();
             invoice = JsonConvert.DeserializeObject<Invoice>(invoiceObj.ToString());
             invoiceList.Add(invoice);
         }
     }
     if (jsonObj.ContainsKey("page_context"))
     {
         var pageContext = new PageContext();
         pageContext = JsonConvert.DeserializeObject<PageContext>(jsonObj["page_context"].ToString());
         invoiceList.page_context = pageContext;
     }
     return invoiceList;
 }
Ejemplo n.º 3
0
 internal static InvoicesList getInvoiceList(HttpResponseMessage responce)
 {
     var invoiceList = new InvoicesList();
     var jsonObj =
         JsonConvert.DeserializeObject<Dictionary<string, object>>(responce.Content.ReadAsStringAsync().Result);
     if (jsonObj.ContainsKey("invoices"))
     {
         var invoicesArray = JsonConvert.DeserializeObject<List<object>>(jsonObj["invoices"].ToString());
         foreach (var invoiceObj in invoicesArray)
         {
             var invoice = new Invoice();
             invoice = JsonConvert.DeserializeObject<Invoice>(invoiceObj.ToString());
             invoiceList.Add(invoice);
         }
     }
     if (jsonObj.ContainsKey("page_context"))
     {
         var pageContext = new PageContext();
         pageContext = JsonConvert.DeserializeObject<PageContext>(jsonObj["page_context"].ToString());
         invoiceList.page_context = pageContext;
     }
     return invoiceList;
 }
Ejemplo n.º 4
0
 public static void AddInvoice(Invoice newInvoice)
 {
     InvoicesList.Add(newInvoice);
     NumberOfInvoices = InvoicesList.Count;
     SaveInvoices();
 }