public SceneViewModelContext(Controller controller, IConfig config, IRepositories repos, IRatingCalculator rating, ISceneHolder sceneHolder)
            : base(controller, config, repos, rating)
        {
            this.SceneHolder = sceneHolder;

            this.LinkableBricks = new Lazy<Dictionary<string,Brick>>(() =>
                this.Repos.SpecialScenes.Single(s => s.SceneId == Constants.LinkableBricksSceneId)
                    .Scene.Walls.SelectMany(w => w.Bricks)
                    .ToDictionary(b => b.BrickId, b => b));
        }
Пример #2
0
 private SceneViewModelContext GetViewModelContext(ISceneHolder sceneHolder)
 {
     return new SceneViewModelContext(this, this.config, this.repos, this.rating, sceneHolder);
 }
Пример #3
0
        public virtual SceneViewModel GetSceneViewModel(ISceneHolder sceneHolder, bool includeTemplates = false)
        {
            var scene = sceneHolder.Scene ?? new Scene();

            var viewModel = scene.ToViewModel(GetViewModelContext(sceneHolder));

            if (includeTemplates)
            {
                viewModel.Templates = this.repos.SpecialScenes
                    .Where(s => s.SceneId != Constants.LinkableBricksSceneId)
                    .Select(s => new SelectListItem
                    {
                        Text = s.Title,
                        Value = s.SceneId
                    });
            }

            return viewModel;
        }