Exemplo n.º 1
0
 public static bool LoadDeliveries()
 {
     try
     {
         DeliveriesList.Clear();
         using (var sr = new StreamReader(FilePath))
         {
             var deSerializer  = new XmlSerializer(typeof(ObservableCollection <Delivery>));
             var tmpCollection =
                 (ObservableCollection <Delivery>)deSerializer.Deserialize(sr);
             foreach (var item in tmpCollection)
             {
                 DeliveriesList.Add(item);
             }
             return(true);
         }
     }
     catch (Exception ex)
     {
         if (ex is FileNotFoundException)
         {
             var sw = new StreamWriter(FilePath);
         }
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
Exemplo n.º 2
0
 public static void AddNewDelivery(Delivery newDelivery)
 {
     DeliveriesList.Add(newDelivery);
     NumberOfDeliveries = DeliveriesList.Count;
     SaveDeliveries();
 }