示例#1
0
        public async Task Create() // todo:validate first wizard page again when creating?
        {
            var uri = FolderName + "\\" + FileName;

            if (!InExistedFile)
            {
                scope = appModel.CreateScope(uri);
            }

            else
            {
                var boards = await scope.GetAllBoardsInFileAsync();

                BoardsInFile.PublishCollection(boards.Select(board => board.Name));

                if (BoardsInFile.Contains(BoardName))
                {
                    await dialogCoordinator.ShowMessageAsync(this, "Can not create board",
                                                             "Board with such name already exists in file");

                    return;
                }
            }

            appModel.AddRecent(uri);

            appModel.SaveConfig();

            var newBoard = new BoardInfo()
            {
                Name     = BoardName,
                Created  = DateTime.Now,
                Modified = DateTime.Now
            };

            newBoard = await scope.CreateOrUpdateBoardAsync(newBoard);

            foreach (var colName in ColumnList.Select(column => column.Name))
            {
                await scope.CreateOrUpdateColumnAsync(new ColumnInfo
                {
                    Name  = colName,
                    Board = newBoard
                });
            }

            foreach (var rowName in RowList.Select(row => row.Name))
            {
                await scope.CreateOrUpdateRowAsync(new RowInfo
                {
                    Name  = rowName,
                    Board = newBoard
                });
            }

            Close();

            shell.ShowDistinctView <BoardView>(uri,
                                               viewRequest: new BoardViewRequest {
                Scope = scope, SelectedBoardName = BoardName
            },
                                               options: new UiShowOptions {
                Title = uri
            });
        }