/// <summary> /// Delete event listener /// </summary> /// <param name="sender">Sender value</param> /// <param name="broadCastEventArgs">BroadCastEventArgs value</param> private void DeleteEventListener(object sender, BroadCastEventArgs broadCastEventArgs) { lock (_locker) { ConfigurationLookupVM configurationLookUp; if (SerializationHelper.TryDeserialize <ConfigurationLookupVM>(broadCastEventArgs.MessageRequest.Message, out configurationLookUp)) { ConfigurationLookupVM configurationLookUpToBeDelete = _configurationLookUps.Where(cl => cl.ID == configurationLookUp.ID).FirstOrDefault(); if (configurationLookUpToBeDelete != null) { // Modify the collection. // 1. Set the configuration lookup object status to Deleted.This is to show the Grid animation related to Delete App.Current.Dispatcher.Invoke(() => { configurationLookUpToBeDelete.Status = Status.Deleted.ToString(); }); // 2. Wait few second and remove the deleted from the collecion. Thread.Sleep(2500); App.Current.Dispatcher.Invoke(() => { ConfigurationLookUpCaches.Remove(configurationLookUpToBeDelete); ConfigurationLookUpCaches.OrderByDescending(cl => cl.ID); }); } } } }
/// <summary> /// Update event listener /// </summary> /// <param name="sender">Sender value</param> /// <param name="broadCastEventArgs">BroadCastEventArgs value</param> private void UpdateEventListener(object sender, BroadCastEventArgs broadCastEventArgs) { lock (_locker) { ConfigurationLookupVM configurationLookUp; if (SerializationHelper.TryDeserialize <ConfigurationLookupVM>(broadCastEventArgs.MessageRequest.Message, out configurationLookUp)) { ConfigurationLookupVM configurationLookUpToBeUpdate = _configurationLookUps.Where(cl => cl.ID == configurationLookUp.ID).FirstOrDefault(); if (configurationLookUpToBeUpdate != null) { // Modify the collection. // 1. Set the configuration lookup object status to Update and update the value App.Current.Dispatcher.Invoke(() => { configurationLookUpToBeUpdate.Status = Status.Updated.ToString(); configurationLookUpToBeUpdate.Name = configurationLookUp.Name; configurationLookUpToBeUpdate.Value = configurationLookUp.Value; }); // 2. Wait few second and set the configuration lookup object status to Default Thread.Sleep(2500); App.Current.Dispatcher.Invoke(() => { configurationLookUpToBeUpdate.Status = Status.Default.ToString(); }); } } } }