コード例 #1
0
        public JsonResult Songs()
        {
            var userId = GetUser();

            var songs      = _songRepository.All(userId);
            var references = _tagRepository.AllReferences(userId);

            foreach (var song in songs)
            {
                var tags = new List <TagReferences>();
                foreach (var reference in references)
                {
                    if (reference.YouTubeId == song.YouTubeId)
                    {
                        var tag = new TagReferences()
                        {
                            TagReferenceId = reference.TagReferenceId,
                            Tag            = reference.Tag,
                            Fixed          = reference.Fixed,
                            Color          = reference.Color
                        };
                        tags.Add(tag);
                    }
                }
                song.Tags = tags;
            }

            songs.OrderBy(s => s.Name).ToList();

            return(Json(new { songs }));
        }