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(); } }