private void AddtoDgv(CalendarItem item) { if (_items.All(x => x.Id != item.Id)) { _items.Add(item.Map()); return; } if (item.SyncStatus.CalenadCalendarItemStatus == CalendarItemStatus.Updated) { var oldItem = _items.FirstOrDefault(x => x.Id == item.Id); if (oldItem != null) { oldItem = item.Map(); } } if (item.SyncStatus.CalenadCalendarItemStatus == CalendarItemStatus.New) { _items.Add(item.Map()); } if (item.SyncStatus.CalenadCalendarItemStatus == CalendarItemStatus.Deleted) { var oldItem = _items.FirstOrDefault(x => x.Id == item.Id); if (oldItem != null) { _items.Remove(oldItem); } } }