/// <summary>
        /// Update a list of discoverers from a received event
        /// </summary>
        /// <param name="results"></param>
        /// <param name="ev"></param>
        public static void Update(this IList <DiscovererInfo> results,
                                  DiscovererEventApiModel ev)
        {
            var discoverer = results.FirstOrDefault(e => e.DiscovererModel.Id == ev.Id);

            if (discoverer == null &&
                ev.EventType != DiscovererEventType.New)
            {
                return;
            }
            switch (ev.EventType)
            {
            case DiscovererEventType.New:
                if (discoverer == null)
                {
                    // Add if not already in list
                    results.Add(new DiscovererInfo {
                        DiscovererModel = ev.Discoverer
                    });
                }
                break;

            case DiscovererEventType.Updated:
                ev.Discoverer.Patch(discoverer.DiscovererModel);
                break;

            case DiscovererEventType.Deleted:
                results.Remove(discoverer);
                break;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// refresh UI on DiscovererEvent
 /// </summary>
 /// <param name="ev"></param>
 private Task DiscovererEvent(DiscovererEventApiModel ev)
 {
     DiscovererList.Results.Update(ev);
     _pagedDiscovererList = DiscovererList.GetPaged(int.Parse(Page), CommonHelper.PageLength, DiscovererList.Error);
     StateHasChanged();
     return(Task.CompletedTask);
 }
Exemplo n.º 3
0
 /// <summary>
 /// refresh UI on DiscovererEvent
 /// </summary>
 /// <param name="ev"></param>
 private Task DiscovererEvent(DiscovererEventApiModel ev)
 {
     Items.Results.Update(ev);
     StateHasChanged();
     return(Task.CompletedTask);
 }