예제 #1
0
        public void TakeData(BtRootModel model)
        {
            this.FinishLoading();

            // important step: datagrid needs to know how many columns are required to fit all the portfolios
            this.Portfolios = model.Portfolios;

            var lines = model.Securities.OrderBy(x => x.Security.Name).Select(x => Helper.As <IBtLineModel>(x)).ToList();

            lines.Add(model);
            this.Lines = lines;

            this.KeptRootModel = model;

            var registeredExpressions = new List <EditableExpressionModel>();

            foreach (var security in model.Securities)
            {
                var securityId = security.Security.Id;
                var basketId   = this.LastBasketId.Value;
                foreach (var portfolioTarget in security.PortfolioTargets)
                {
                    var portfolioId = portfolioTarget.BroadGlobalActivePortfolio.Id;

                    var requestCommentsCommand = new DelegateCommand(delegate
                    {
                        this.RequestComments(basketId, portfolioId, securityId);
                    });
                    var expression = portfolioTarget.PortfolioTarget;
                    expression.RegisterForBeingWatched(this, requestCommentsCommand);
                    registeredExpressions.Add(expression);
                }
                var requestBaseCommentsCommand = new DelegateCommand(delegate
                {
                    this.RequestComments(this.LastTargetingTypeGroupId.Value, basketId, securityId);
                });
                var baseExpression = security.Base;
                baseExpression.RegisterForBeingWatched(this, requestBaseCommentsCommand);
                registeredExpressions.Add(baseExpression);
            }

            this.OnGotData();



            // setting the focus
            foreach (var expression in registeredExpressions)
            {
                if (expression.IsLastEdited)
                {
                    expression.IsFocusSet   = true;
                    expression.IsLastEdited = false;
                }
            }
        }
예제 #2
0
 public void Resolve(BtRootModel model)
 {
     this.Result = this.selector.TotalTemplate;
 }