void OnWebsiteCreatedOrUpdated(ExtendedEventArgs <GenericWebsiteEventArgs> args) { if (args == null) { return; } if (WebsiteViewModels.Any(ws => ws.Website.Id == args.Data.Website.Website.Id)) // Updated { var wvm = WebsiteViewModels.SingleOrDefault(w => w.Website.Id == args.Data.Website.Website.Id); if (wvm != null) { wvm.Website = args.Data.Website.Website; } } else // new { WebsiteViewModels.Add(args.Data.Website); //var msg = String.Format("Website {0} has been added", vm.Website.Name); Events.GetEvent <GenericNotificationEvent>().Publish(args.Data.Message); SelectedWebsite = args.Data.Website; // SZ: commented out duplicate call //Events.GetEvent<GenericNotificationEvent>().Publish(args.Data.Message); } }
//void OnWebsiteUpdated(WebsiteViewModel vm) //{ // // TODO: re-apply the sortby function now in case the current sort-property was changed on the website. // var msg = String.Format("Website {0} has been updated", vm.Website.Name); // EventAggregator.GetEvent<GenericNotificationEvent>().Publish(msg); // WebsitesCVS.View.Refresh(); // SelectedWebsite = vm; //} void OnWebsiteDeleted(WebsiteViewModel vm) { var name = vm.Website.Name; WebsiteViewModels.Remove(vm); var msg = String.Format("Website {0} has been deleted", name); Events.GetEvent <GenericNotificationEvent>().Publish(msg); WebsitesCVS.View.Refresh(); // Select the 1st one in the list or null. // TODO: better to select 1 below the one just deleted. SelectedWebsite = WebsiteViewModels.Any() ? WebsiteViewModels[0] : null; }