public void Delete(AppointmentDeletedEventArgs e)
        {
            var appointment = (Appointment)(e.Appointment);
            using (var db = new AppointmentContext())
            {

                var findAppInDB = db.AppointmentModels.FirstOrDefault(applic => applic.Id == appointment.UniqueId);
                db.AppointmentModels.Remove(findAppInDB);
                db.SaveChanges();
            }
        }
 public void Edit(AppointmentEditedEventArgs e)
 {
     var appointment = (Appointment)(e.Appointment);
     using (var db = new AppointmentContext())
     {
         var findAppInDB = db.AppointmentModels.FirstOrDefault(applic => applic.Id == appointment.UniqueId);
         findAppInDB.StartTime = appointment.Start;
         findAppInDB.EndTime = appointment.End;
         findAppInDB.Subject = appointment.Subject;
         findAppInDB.Body = appointment.Body;
         db.SaveChanges();
     }
 }
 public void Save(AppointmentCreatedEventArgs e)
 {
     using (var db = new AppointmentContext())
     {
         var appointment = (Appointment)(e.CreatedAppointment);
         var newAppointment = new AppointmentModel()
         {
             Id = appointment.UniqueId,
             StartTime = appointment.Start,
             EndTime = appointment.End,
             Subject = appointment.Subject,
             Body = appointment.Body
         };
         db.AppointmentModels.Add(newAppointment);
         db.SaveChanges();
     }
 }
 private ObservableCollection<Appointment> Load()
 {
     using (var db = new AppointmentContext())
     {
         var collection = new ObservableCollection<Appointment>();
         try
         {
         var findApps = db.AppointmentModels.Select(app => app);
         if (findApps.Count() > 0)
         {
             foreach (var app in findApps)
             {
                 var appoint = new Appointment();
                 appoint.UniqueId = app.Id;
                 appoint.Start = app.StartTime;
                 appoint.End = app.EndTime;
                 appoint.Subject = app.Subject;
                 appoint.Body = app.Body;
                 collection.Add(appoint);
             }
         }
         }
         catch
         { }
         return collection;
     }
 }