public MusicFolder.ResultInfo MoveFile(string filePath, HashTagModel fileHashTagModel) { var matchPath = GetMatchPath(fileHashTagModel); var matchFileMusicFolder = pathMusicFolderDictionary[matchPath]; var isDeprecated = fileHashTagModel.Contains(MusicFolder.DeprecatedHashTag); return(isDeprecated ? matchFileMusicFolder.DeprecatedFolder.MoveFile(filePath, true) : matchFileMusicFolder.MoveFile(filePath)); }
public string GetMatchPath(HashTagModel model) { try { return(patternFolderDictionary.First(pair => model.IsSupersetOf(pair.Key.Model)).Value); } catch (InvalidOperationException) { throw new NoMatchPatternException(); } }
public IHttpActionResult GetHashtag(int id) { Hashtag hashtag = db.Hashtags.Include(l => l.POIs).Where(l => l.ID == id).SingleOrDefault(); if (hashtag == null) { return(NotFound()); } HashTagModel newMdlHash = new HashTagModel(hashtag); return(Ok(newMdlHash)); }
// GET: api/Hashtags public IEnumerable <HashTagModel> GetHashtags() { IEnumerable <Hashtag> hashList = db.Hashtags.ToList(); List <HashTagModel> newHashList = new List <HashTagModel>(); foreach (var hash in hashList) { Hashtag newHashtag = db.Hashtags.Include(l => l.POIs).Where(l => l.ID == hash.ID).SingleOrDefault(); HashTagModel newMdl = new HashTagModel(hash); newHashList.Add(newMdl); } return(newHashList); }
public void Add(string path, HashTagModel model, int priority = 0) { Contract.Requires(path != null); Contract.EndContractBlock(); path = PathExtension.Normalize(path); if (!pathMusicFolderDictionary.ContainsKey(path)) { var musicFolder = new MusicFolder(path); pathMusicFolderDictionary[path] = musicFolder; } var pattern = new HashTagModelPattern(model, priority); if (patternFolderDictionary.ContainsKey(pattern)) { throw new PatternAlreadyExistsException(); } patternFolderDictionary.Add(pattern, path); }
public bool HasPattern(HashTagModel model) { return(patternFolderDictionary.Keys.Any(pattern => pattern.Model == model)); }
public bool Match(HashTagModel model) { return(patternFolderDictionary.Keys.Any(pattern => model.IsSupersetOf(pattern.Model))); }
public HashTagModelPattern(HashTagModel model, int priority) { Model = model; Priority = priority; }