Beispiel #1
0
        public void Reload()
        {
            var bw = new BackgroundWorker();

            bw.DoWork += (sender, e) =>
            {
                e.Result = _loanRepository.GetAlerts(TimeProvider.Now, User.CurrentUser.Id);
            };
            bw.RunWorkerCompleted += (sender, e) =>
            {
                _view.StopProgress();
                if (e.Error != null)
                {
                    _errorView.Run(e.Error.Message);
                    return;
                }
                _alerts = (List <Model.Alert>)e.Result;
                Refresh();
            };
            _view.StartProgress();
            bw.RunWorkerAsync();
        }
        public void Reload()
        {
            var bw = new BackgroundWorker();

            bw.DoWork += (sender, e) =>
            {
                e.Result = _loanRepository.GetAlerts(TimeProvider.Now, User.CurrentUser.Id);
            };
            bw.RunWorkerCompleted += (sender, e) =>
            {
                _view.StopProgress();
                if (e.Error != null)
                {
                    _errorView.Run(e.Error.Message);
                    return;
                }
                _alerts = (List <Model.Alert>)e.Result;
                Refresh();
            };
            _view.StartProgress();
            bw.RunWorkerAsync();

            //slycode
            var bw1 = new BackgroundWorker();

            bw1.DoWork += (sender, e) =>
            {
                e.Result = _clientRepository.GetAlerts(TimeProvider.Now, User.CurrentUser.Id);
            };
            bw1.RunWorkerCompleted += (sender, e) =>
            {
                _view.StopProgress();
                if (e.Error != null)
                {
                    _errorView.Run(e.Error.Message);
                    return;
                }
                var result = (List <Model.Alert>)e.Result;
                foreach (Model.Alert alert in result)
                {
                    if (_alerts.Contains(alert))
                    {
                        Model.Alert eAlert = _alerts.Find(a => a.Id == alert.Id);
                        eAlert.Id = alert.Id;
                        //eAlert.Kind = OpenCBS.ArchitectureV2.Model.Alert.AlertKind.Client;
                        eAlert.ClientStatus = alert.ClientStatus;
                        eAlert.Date         = alert.Date;
                        eAlert.ClientName   = alert.ClientName;
                        eAlert.Address      = alert.Address;
                        eAlert.Phone        = alert.Phone;
                        eAlert.BranchName   = alert.BranchName;
                    }
                    else
                    {
                        _alerts.Add(alert);
                    }
                }
                Refresh();
            };
            _view.StartProgress();
            bw1.RunWorkerAsync();
        }