Esempio n. 1
0
        public JsonResult GetAllTags()
        {
            var userId = GetUser();
            var tags   = _tagRepository.All(userId);

            return(Json(new
            {
                tags
            }));
        }
        public void Playlist([FromBody] List <Songs> songs)
        {
            var userId = GetUser();

            var distinctSongs = songs.GroupBy(s => s.YouTubeId).Select(s => s.OrderBy(x => x.YouTubeId).First()).ToList();

            var currentTags = _tagRepository.All(userId);

            var playlists  = songs.ToLookup(s => s.Playlist);
            var references = new List <TagReferences>();

            foreach (var playlist in playlists)
            {
                var tagId = 0;
                if (!currentTags.Any(t => t.Tag == playlist.Key))
                {
                    tagId = _tagRepository.Upload(userId, playlist.Key, 1, null);
                }
                else
                {
                    tagId = currentTags.Where(t => t.Tag == playlist.Key).Select(t => t.TagId).First();
                }

                foreach (var song in playlist)
                {
                    references.Add(new TagReferences()
                    {
                        TagId     = tagId,
                        YouTubeId = song.YouTubeId,
                        UserId    = userId
                    });
                }
            }

            try
            {
                _songRepository.BulkUpload(userId, distinctSongs);
                _tagRepository.BulkUploadReferences(references);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
Esempio n. 3
0
        public JsonResult GetTagList()
        {
            var tagList = _tagRepository.All();

            List <TagModel> objList = new List <TagModel>();

            foreach (var item in tagList)
            {
                TagModel obj = new TagModel
                {
                    Id          = item.Id,
                    Name        = item.Name,
                    UrlSlug     = item.UrlSlug,
                    Description = item.Description
                };
                objList.Add(obj);
            }

            return(Json(objList, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
 public WidgetViewModel(PostRepository postRepository, TagRepository tagRepository, CategoryRepository categoryRepository)
 {
     Categories  = categoryRepository.All().ToList();
     Tags        = tagRepository.All().ToList();
     LatestPosts = postRepository.All().ToList();
 }