public async Task Handle(EditCmd message, CancellationToken token) { var item = await _session.Get <Table>(message.Id, message.ExpectedVersion, token); item.Edit(message); await _session.Commit(token); }
public void Edit(EditCmd command) { // check valid for command //if (string.IsNullOrEmpty(newName)) throw new ArgumentException("newName"); Id = command.Id; Code = command.NewCode; Name = command.NewName; Capacity = command.NewCapacity; LocationId = command.NewLocationId; Description = command.NewDescription; ApplyChange(new EdittedEvent(Id, Code, Name, Capacity, LocationId, Description)); }
public override string createEntry(string _name, string type) { int parent = -1; UndoableCmd cmd1 = new EditCmd(node); if (_name != null) //点击文件夹创建 { parent = MemoryInterface.getInstance().getInodeIndexByName(node, _name); //选中文件夹为父目录 } else //直接新建 { parent = node; //当前目录为父目录 } List <int> nodeLoc = MemoryInterface.getInstance().getRequireInodes(1); //找到未使用的inode节点 List <int> blockLoc = MemoryInterface.getInstance().getRequireBlocks(1); //找到空闲磁盘块 if (nodeLoc == null || blockLoc == null) //inodeMap或blockMap用尽 { return(null); } string name = null; if (type.Equals("文件夹")) { name = initDir(blockLoc, parent, nodeLoc[0]); entries.Add(new Directory(nodeLoc[0], name)); } else { name = "新建文件"; name = MemoryInterface.getInstance().addNewInodeTableItem(MemoryInterface.getInstance().getInodeByIndex(parent).getBlock(0), name, nodeLoc[0]); inode temp = MemoryInterface.getInstance().getInodeByIndex(nodeLoc[0]); temp.init(nodeLoc[0], blockLoc, "文件", DateTime.Now); entries.Add(new File(temp, name)); } UndoableCmd cmd2 = new AddCmd(nodeLoc[0]); CompoundCmd cmd3 = new CompoundCmd(); cmd3.newOpe(cmd1); cmd3.newOpe(cmd2); UndoManager.getInstance().newOpe(cmd3); MemoryInterface.getInstance().write(); return(name); }