protected override Pot Handle(PresentPotRequest request) { Pot pot = potRepository.Get(request.PotName); pot.Snapshots = snapshotRepository.GetByPot(request.PotName).ToList(); return(pot); }
private Pot RetrievePot(CreateSnapshotRequest request) { Pot pot = potRepository.Get(request.PotName); if (pot == null) { throw new PotDoesNotExistException(request.PotName); } return(pot); }
protected override List <Pot> Handle(PresentPotsRequest request) { return(potRepository.Get() .OrderBy(x => x.Name) .ToList()); }
protected override void Handle(ImportSnapshotRequest request) { //ISnapshotReader reader = null; //ISnapshotWriter writer = null; //while (reader.MoveNext()) //{ // switch (reader.CurrentItemType) // { // case SnapshotItemType.None: // break; // case SnapshotItemType.SerializerId: // writer.WriteSerializerId(reader.ReadSerializerId()); // break; // case SnapshotItemType.OriginalPath: // writer.WriteOriginalPath(reader.ReadOriginalPath()); // break; // case SnapshotItemType.CreationTime: // writer.WriteCreationTime(reader.ReadCreationTime()); // break; // case SnapshotItemType.FileCollection: // IEnumerable<HFile> files = reader.ReadFiles(); // foreach (HFile file in files) // writer.Add(file); // break; // case SnapshotItemType.DirectoryCollection: // IEnumerable<HDirectoryReader> directories = reader.ReadDirectories(); // foreach (HDirectory directory in directories) // writer.Add(directory); // break; // } //} Snapshot snapshot = potImportExport.ReadSnapshot(request.FilePath); Pot pot = potRepository.Get(request.PotName); if (pot == null) { pot = new Pot { Name = request.PotName, Path = snapshot.OriginalPath }; potRepository.Add(pot); } else { if (pot.Path != snapshot.OriginalPath) { throw new Exception("The url of the imported snapshot is different than the one of the pot."); } } snapshotRepository.Add(request.PotName, snapshot); }