private async void ExecuteCreateWith(object arg)
        {
            if (reportToEdit != null)
            {
                //do an edit with this designer, not a create
                EditWith(arg);
                return;
            }
            // get and set up the right filler and designer
            var metaF    = ReportTypesCV.CurrentItem as IReportType;
            var metaD    = arg as IReportDesigner;
            var designer = designerService.GetDesigner(metaD.Name); // refactored the meta out of here, a bit unnecessary, but if you ever switch back...

            PossibleDesigners = null;
            DesignersCV.MoveCurrentTo(metaD);
            // create report instance and load with designer
            ReportInfo rep = await reprepo.CreateNewAsync(metaF.Name, "New report");

            Reports.Insert(0, rep);
            designer.Load(rep);
            ActiveDesigner = designer;

            ScreenState = ScreenStates.DesignerState;
            raise();
        }
        private async void EditWith(object arg)
        {
            var metaD    = arg as IReportDesigner;
            var designer = designerService.GetDesigner(metaD.Name);

            PossibleDesigners = null;
            DesignersCV.MoveCurrentTo(metaD);
            // we don't have the script or template yet. get the script now.
            reportToEdit.Script = await reprepo.GetScriptAsync(reportToEdit.ID);

            designer.Load(reportToEdit);
            ActiveDesigner = designer;
            ScreenState    = ScreenStates.DesignerState;
            raise();
            reportToEdit = null;
        }
 public DesignMainViewModel(IReportingService reportingService, IReportDesignerService designerService, IReportRepository reprepo)
 {
     this.reportingService = reportingService;
     this.designerService  = designerService;
     this.reprepo          = reprepo;
     CreateCommand         = new DelegateCommand(ExecuteCreate);
     CreateWithCommand     = new DelegateCommand <object>(ExecuteCreateWith);
     EditCommand           = new DelegateCommand(ExecuteEdit, CanExecuteEdit);
     DeleteCommand         = new DelegateCommand(ExecuteDelete, CanExecuteDelete);
     BackCommand           = new DelegateCommand(ExecuteBack);
     ReportTypesMessage    = "Installed Report Types";
     ScreenState           = ScreenStates.HomeState;
     ReportTypesCV         = CollectionViewSource.GetDefaultView(reportingService.AvailableReportTypes);
     DesignersCV           = CollectionViewSource.GetDefaultView(designerService.AvailableReportDesigners);
     ReportTypesCV.MoveCurrentTo(null);
     DesignersCV.MoveCurrentTo(null);
     ReportTypesCV.CurrentChanged += ReportTypesCV_CurrentChanged;
 }