示例#1
0
        //GET /Song/Index/
        public ActionResult Index(string artist, string song, string genre)
        {
            ViewBag.showNav = true;
            SongPageViewModel pageModel = new SongPageViewModel();

            //Is loged
            if (Session["user"] != null && Session["user"].GetType() == (typeof(ViewUser)))
            {
                pageModel.user = (ViewUser)(Session["user"]);
            }

            Neo4jDataProvider dbNeo4j = new Neo4jDataProvider();
            RedisDataProvider dbRedis = new RedisDataProvider();

            dbRedis.IncrementSongVisitCount(artist + " - " + song);


            #region NavBarData

            if (genre == "All" || genre == "")
            {
                pageModel.genre = null;
            }
            else
            {
                pageModel.genre = genre;
            }

            //Getting artists
            pageModel.artists = dbNeo4j.ArtistRead(pageModel.genre);
            for (char c = 'A'; c <= 'Z'; c++)
            {
                if (pageModel.artists.ContainsKey(c.ToString()))
                {
                    List <ViewArtist> tmp = pageModel.artists[c.ToString()];
                    pageModel.artists[c.ToString()] = tmp.OrderBy(x => x.name).ToList();
                }
            }


            //Getting genres
            pageModel.genres = dbNeo4j.GenreRead();
            pageModel.genres.Sort();

            #endregion

            //Getting artist songs
            pageModel.artistSongs = dbNeo4j.SongReadArtistSongs(artist);
            pageModel.artistSongs = pageModel.artistSongs.OrderBy(x => x.artist + " - " + x.name).ToList();

            //Getting song data
            pageModel.song = dbNeo4j.SongRead(artist, song);

            //Getting song comment
            pageModel.comments = dbNeo4j.CommentRead(artist, song);

            //Check is song favorite
            if (pageModel.user != null)
            {
                pageModel.favorite = dbNeo4j.SongCheckIsFavorite(song, artist, pageModel.user.name);
            }

            pageModel.artist = artist;

            return(View(pageModel));
        }