I'm doing the synchronization between the two lists.
IList<Event> GoogleEvents
and Table<myEvent> DB.Events;
On google side i'm using this
String Summary,
String Description,
EventDateTime Start,
EventDateTime End,
Event.RemindersData Reminders;
On db side like this
my code is like this
foreach (myEvent item in DB.Events)
{
if (item.GoogleID == "" || item.GoogleID == null)// i add event my db
{
//Add dbEvent to google and save id to googleid column
}
}
foreach (Event item in myGoogleCalendar.Items)
{
if (DB.Events.Where(o => o.GoogleID == item.Id).Count() == 0)// i add event google
{
//Add googleEvent to dbEvent
}
else
{
//This event also existing in two server
myEvent dbEvent = DB.Olaylar.Where(o => o.GoogleID == item.Id).First();
if(item.Updated.Value == dbEvent.UpdateTime) continue;//Same
if (item.Updated.Value > dbEvent.UpdateTime)
{
//Google event is new
}
else
{
//dbEvent is new
}
}
}
There is one big problem : I forgot deletion
Where should I add deleting events part and how ?
else if (!item.IsDeleted && !string.IsNullOrEmpty(item.GoogleID))
block. if an event in my db has googleIDisDeleted flag = true;
But why don't check is not in google. Indeed i must not modify db. Maybe that will work. But if db is change everything change. – Loathly