Exemple #1
0
 private void Pin()
 {
     try
     {
         using (var db = new ForecastContext())
         {
             db.Database.EnsureCreated();
             var item = new ForecastDbitem
             {
                 Place     = Place,
                 Degrees   = Degrees,
                 Condition = Condition,
                 ImageUrl  = ImageUrl
             };
             db.Add(item);
             db.SaveChanges();
             db.Entry(item).GetDatabaseValues();
             _dbId = item.ForecastDbitemId;
         }
         Pinned = true;
     }
     catch (Exception exception)
     {
         new MessageDialog(exception.Message).ShowAsync();
     }
 }
Exemple #2
0
 public void UnPin()
 {
     if (Pinned)
     {
         using (var db = new ForecastContext())
         {
             db.Database.EnsureCreated();
             var item = db.Items.First(x => x.ForecastDbitemId == _dbId);
             if (item != null)
             {
                 db.Items.Remove(item);
                 db.SaveChanges();
             }
         }
         Pinned = false;
     }
 }