Esempio n. 1
0
 private void OnPeFundCollectionAction(PeFundCollectionAction obj)
 {
     if (peFunds == null)
     {
         var task = LoadPefundsAsync();
     }
     if (obj.action == CollectionAction.removed)
     {
         PeFund fund = peFunds.FirstOrDefault(i => i.Id == obj.fund.Id);
         peFunds.Remove(fund);
     }
     else if (obj.action == CollectionAction.added)
     {
         peFunds.Add(obj.fund);
     }
     else if (obj.action == CollectionAction.updated)
     {
         PeFund fund = peFunds.FirstOrDefault(i => i.Id == obj.fund.Id);
         fund.FundHqTrustNumber = obj.fund.FundHqTrustNumber;
         fund.FundName          = obj.fund.FundName;
         fund.FundShortName     = obj.fund.FundShortName;
         fund.FundLegalName     = obj.fund.FundLegalName;
     }
     else if (obj.action == CollectionAction.reload)
     {
         var task = LoadPefundsAsync();
     }
 }
        private void UpdateOrInsertPeFund()
        {
            try
            {
                if (SelectedFund.Id == 0)
                {
                    PefundAccess.InsertPeFund(SelectedFund);

                    //PeFundSelection will be informed about a new PeFund to add the new investor to its list
                    PeFundCollectionAction parameter = new PeFundCollectionAction()
                    {
                        action = CollectionAction.added,
                        fund   = SelectedFund
                    };
                    eventAggregator.GetEvent <PeFundCollectionActionEvent>().Publish(parameter);
                    eventAggregator.GetEvent <StatusBarEvent>().Publish($"Der PeFund  {SelectedFund.FundShortName} wurde in die Datenbank eingetragen");
                }
                else
                {
                    // update investor

                    PefundAccess.UpdatePeFund(SelectedFund);

                    //InvestorSelection will be informed about changes of an Investor to show the new information
                    PeFundCollectionAction parameter = new PeFundCollectionAction()
                    {
                        action = CollectionAction.updated,
                        fund   = SelectedFund
                    };
                    eventAggregator.GetEvent <PeFundCollectionActionEvent>().Publish(parameter);
                    eventAggregator.GetEvent <StatusBarEvent>().Publish($"Der Fund {SelectedFund.FundShortName} wurde in der Datenbank geändert");
                }
            }
            catch (Exception ex)
            {
                NotificationRequest.Raise(new Notification()
                {
                    Title = ApplicationNames.NotificationTitle, Content = ex.Message
                });
            }
        }
        private void OnConfirmationResponse(IConfirmation obj)
        {
            if (!obj.Confirmed)
            {
                return;
            }

            // Fund wird gelöscht
            try
            {
                PefundAccess.RemovePeFund(SelectedFund);
            }
            catch (Exception ex)
            {
                NotificationRequest.Raise(new Notification()
                {
                    Title   = ApplicationNames.NotificationTitle,
                    Content = ex.Message
                });
                return;
            }


            // InvestorSelection wird informiert

            PeFundCollectionAction parameter = new PeFundCollectionAction()
            {
                action = CollectionAction.removed,
                fund   = SelectedFund
            };

            eventAggregator.GetEvent <PeFundCollectionActionEvent>().Publish(parameter);

            // Unsubscribe Event(s)
            eventAggregator.GetEvent <AccountCollectionEvent>().Unsubscribe(accountListToken);

            // get the current active view (myself) and remove that view from tabcontrol
            var view = regionManager.Regions[RegionNames.TabControlRegion].ActiveViews.ElementAt(0);

            regionManager.Regions[RegionNames.TabControlRegion].Remove(view);
        }