Пример #1
0
        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();
            }
        }
Пример #2
0
 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();
     }
 }
Пример #3
0
 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();
     }
 }