Ejemplo n.º 1
0
        private void UpdateEvent(Event item)
        {
            //var calendarId = GetCalendarId(item.Type);
            var googleCalendarEventId = AlreadyCreatedItems[item.EventGuid].GoogleCalendarEventId;
            var calendarId            = AlreadyCreatedItems[item.EventGuid].GoogleCalendarId;

            var googleCalendarEvent = SyncGoogleCalendarAPI.GetEvent(this.Account, googleCalendarEventId, calendarId);
            var lastSyncAccountLogItemModyficationDate = CalendarSyncBL.GetLastSyncAccountLogItemModyficationDate(item.EventGuid);

            if (GoogleEventDeleted(googleCalendarEvent))
            {
                MarkEventInDatabaseAsDeleted(googleCalendarEventId);
            }
            else
            {
                if (GoogleEventIsMoreUpdatedThanPS(googleCalendarEvent, lastSyncAccountLogItemModyficationDate))
                {
                    //  throw new Exception("what the f**k");
                    UpdateEventInPSTable(googleCalendarEvent, this.Account);
                    CalendarSyncBL.UpdateLogItem(item.EventGuid, googleCalendarEvent.Updated.Value);
                }

                if (PSEventIsMoreUpdatedThanGoogle(googleCalendarEvent, lastSyncAccountLogItemModyficationDate))
                {
                    var @event = UpdateEventInGoogleCalendar(this.Account, item, googleCalendarEvent, calendarId);
                    CalendarSyncBL.UpdateLogItem(item.EventGuid, @event.Updated.Value);
                }
            }
        }
Ejemplo n.º 2
0
        private void DeleteEvent(Event item)
        {
            //var calendarId = GetCalendarId(item.Type);
            var googleCalendarEventId = AlreadyCreatedItems[item.EventGuid].GoogleCalendarEventId;
            var calendarId            = AlreadyCreatedItems[item.EventGuid].GoogleCalendarId;

            SyncGoogleCalendarAPI.Delete(this.Account, googleCalendarEventId, calendarId);
            CalendarSyncBL.SyncAccountEventMarkAsDeleted(googleCalendarEventId);

            var googleCalendarEvent = SyncGoogleCalendarAPI.GetEvent(this.Account, googleCalendarEventId, calendarId);

            CalendarSyncBL.UpdateLogItem(item.EventGuid, googleCalendarEvent.Updated.Value);
        }