示例#1
0
        public IncidentsVM(DialogService dialogService, RescueClient rescueClient, IDialogCoordinator dialogCoordinator)
        {
            this.dialogService     = dialogService;
            this.rescueClient      = rescueClient;
            this.dialogCoordinator = dialogCoordinator;

            LoadIncidents();

            MessengerInstance.Register <Messages.AddEditResultMessage <Incident> >(this, rslt =>
            {
                if (rslt.Error == null)
                {
                    var existingIncident = Incidents.Where(i => i.id == rslt.Entity.id)
                                           .FirstOrDefault();
                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        if (existingIncident != null)
                        {
                            Incidents.Remove(existingIncident);
                        }
                        Incidents.Add(rslt.Entity);
                    });
                }
            });
        }
示例#2
0
 private void LoadIncidents()
 {
     Incidents.Clear();
     rescueClient.GetIncidents((ex, _incidents) =>
     {
         if (ex == null)
         {
             foreach (var i in _incidents)
             {
                 DispatcherHelper.CheckBeginInvokeOnUI(() =>
                 {
                     Incidents.Add(i);
                 });
             }
         }
     });
 }