Example #1
0
        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));
        }
Example #2
0
 public string GetMatchPath(HashTagModel model)
 {
     try
     {
         return(patternFolderDictionary.First(pair => model.IsSupersetOf(pair.Key.Model)).Value);
     }
     catch (InvalidOperationException)
     {
         throw new NoMatchPatternException();
     }
 }
Example #3
0
        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));
        }
Example #4
0
        // 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);
        }
Example #5
0
        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);
        }
Example #6
0
 public bool HasPattern(HashTagModel model)
 {
     return(patternFolderDictionary.Keys.Any(pattern => pattern.Model == model));
 }
Example #7
0
 public bool Match(HashTagModel model)
 {
     return(patternFolderDictionary.Keys.Any(pattern => model.IsSupersetOf(pattern.Model)));
 }
 public HashTagModelPattern(HashTagModel model, int priority)
 {
     Model    = model;
     Priority = priority;
 }