Ejemplo n.º 1
0
        //GET /User/DeleteArtist/
        public ActionResult DeleteArtist(string name)
        {
            //Samo admin brise zanr
            if (Session["user"] == null || ((ViewUser)Session["user"]).admin == false)
            {
                return(Redirect("/"));
            }


            if (name == null || name == "")
            {
                return(Redirect("/User/"));
            }


            Neo4jDataProvider dbNeo4j = new Neo4jDataProvider();

            List <string> check = dbNeo4j.ArtistRead();

            if (!check.Contains(name))
            {
                return(Redirect("/User/#deleteArtistModal"));
            }
            else
            {
                dbNeo4j.ArtistDelete(name);
                return(Redirect("/User/"));
            }
        }
Ejemplo n.º 2
0
        // GET: /Search/
        public ActionResult Index(string text, string genre)
        {
            Neo4jDataProvider dbNeo4j = new Neo4jDataProvider();
            RedisDataProvider dbRedis = new RedisDataProvider();

            ViewBag.showNav = true;
            SearchPageViewModel pageModel = new SearchPageViewModel();


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



            List <string> redisResults = dbRedis.AutoComplete(pageModel.user != null ? pageModel.user.name : null, text, false);

            #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.matched = dbNeo4j.SearchResults(redisResults);
            pageModel.matched = pageModel.matched.OrderBy(x => x.artist + " - " + x.name).ToList();

            pageModel.text = text;

            return(View(pageModel));
        }
        // GET: /Artist/Index
        public ActionResult Index(string artist, string genre)
        {
            ArtistPageViewModel pageModel = new ArtistPageViewModel();

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

            #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();

            //Geting artist info
            pageModel.artist = dbNeo4j.ArtistReadOne(artist);

            ViewBag.showNav = true;
            return(View(pageModel));
        }
Ejemplo n.º 4
0
        //GET /User/CreateArtist/
        public ActionResult CreateArtist(string name, string bio, string website, string genres)
        {
            //Samo admin dodaje izvodjaca
            if (Session["user"] == null || ((ViewUser)Session["user"]).admin == false)
            {
                return(Redirect("/"));
            }

            if (name == null || name == "" || bio == null || bio == "" || website == null || website == "" || genres == null || genres == "")
            {
                return(Redirect("/User/"));
            }

            Neo4jDataProvider dbNeo4j = new Neo4jDataProvider();

            List <string> checkArtists = dbNeo4j.ArtistRead();

            if (checkArtists.Contains(name))
            {
                return(Redirect("/User/#addArtistModal"));
            }
            else
            {
                string        genresClean     = Regex.Replace(genres, " *, *", ",");
                List <string> genreNames      = genresClean.Split(',').ToList();
                List <string> checkGenres     = dbNeo4j.GenreRead();
                List <string> validGenreNames = genreNames.Intersect(checkGenres).ToList();
                List <Genre>  validGenres     = new List <Genre>();
                foreach (string genreName in validGenreNames)
                {
                    Genre tmp = new Genre();
                    tmp.name = genreName;
                    validGenres.Add(tmp);
                }

                if (validGenres == null)
                {
                    return(Redirect("/User/"));
                }

                Artist artist = new Artist();
                artist.name      = name;
                artist.biography = bio;
                artist.website   = website;
                artist.link      = "/" + artist;
                dbNeo4j.ArtistCreate(artist, validGenres);
                return(Redirect("/User/"));
            }
        }
Ejemplo n.º 5
0
        // GET /User/Index
        public ActionResult Index(String genre)
        {
            UserPageViewModel pageModel = new UserPageViewModel();

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

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

            #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

            //Geting user created songs
            pageModel.userSongs = dbNeo4j.GetUserSongsAndDrafts(pageModel.user.name);

            //Geting user favorite songs
            pageModel.favoritSongs = dbNeo4j.UserGetFavoriteSongs(pageModel.user.name);

            //Getting user admin notification count
            pageModel.adminNotifications = dbRedis.GetAdminNotificationsCount();

            //Geting user admin request songs
            pageModel.requestedSongs = dbNeo4j.SongDraftRead();

            //User List
            pageModel.userList = dbNeo4j.UserRead();

            //Getting statistics
            pageModel.songCount = dbRedis.GetSongCount();
            if (pageModel.songCount == null || pageModel.songCount == "")
            {
                pageModel.songCount = "0";
            }
            pageModel.artistCount = dbRedis.GetArtistCount();
            if (pageModel.artistCount == null || pageModel.artistCount == "")
            {
                pageModel.artistCount = "0";
            }
            pageModel.genreCount = dbRedis.GetGenreCount();
            if (pageModel.genreCount == null || pageModel.genreCount == "")
            {
                pageModel.genreCount = "0";
            }

            ViewBag.showNav = true;
            return(View(pageModel));
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
0
        //GET /Song/Approve/
        public ActionResult Approve(string user, string artist, string name, string content, string approve)
        {
            ViewBag.showNav = false;
            //Samo admin moze da appruvuje
            if (Session["user"] == null || ((ViewUser)Session["user"]).admin == false)
            {
                return(Redirect("/"));
            }

            PageViewModel pageModel = new PageViewModel();

            pageModel.user = (ViewUser)(Session["user"]);

            Neo4jDataProvider dbNeo4j = new Neo4jDataProvider();

            if (approve != null)
            {
                //Promenjeni podatci
                ViewSong draft = new ViewSong();
                draft.creator  = user;
                draft.name     = name;
                draft.content  = content;
                draft.artist   = artist;
                draft.approved = false;
                draft.date     = DateTime.Now.ToString("dd-MM-yyyy");

                ViewBag.draft = draft;
                if (artist == null && name == null && content == null)
                {
                    return(View(pageModel));
                }
                if (artist == null || name == null || content == null)
                {
                    ViewBag.error = "Data is missing from required fields.";
                }
                else if (artist.Length < 1 || name.Length < 1 || content.Length < 1)
                {
                    ViewBag.error = "Data is missing from required fields.";
                }

                if (ViewBag.error != null)
                {
                    return(View(pageModel));
                }

                //Provera da li postoji Artist
                List <string> allArtists = dbNeo4j.ArtistRead();
                if (!allArtists.Contains(artist))
                {
                    ViewBag.noArtist = true;
                    return(View(pageModel));
                }


                //Kriranje nove pesme
                Song song = new Song();
                song.name    = name;
                song.content = content;
                song.date    = DateTime.Now.ToString("dd-MM-yyyy");
                song.link    = "/" + artist + "/" + user + "/";

                dbNeo4j.SongCreate(song, user, artist);
                SongDraft songDraft = new SongDraft();
                songDraft.name   = name;
                songDraft.artist = artist;
                dbNeo4j.SongDraftDelete(songDraft, user);
                dbNeo4j.SongRequestDelete(artist, name);

                return(Redirect("/User/"));
            }
            ViewBag.draft = dbNeo4j.SongDraftRead(user, artist, name);

            return(View(pageModel));
        }
Ejemplo n.º 8
0
        //GET /Home/Index
        public ActionResult Index(string genre)
        {
            #region Inicijalizacija baza podataka

            DBInitializer initializator = new DBInitializer();
            initializator.Initialize();

            #endregion


            HomePageViewModel pageModel = new HomePageViewModel();

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

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

            #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 popular songs
            List <string> popularSongNames = dbRedis.GetMostPopularSongs(10);
            pageModel.popularSongs = dbNeo4j.SongRead(popularSongNames);

            //Getting latest songs
            List <string> latestSongNames = dbRedis.GetLatestSongs();
            pageModel.latestSongs = dbNeo4j.SongRead(latestSongNames);

            //Getting songs requests
            pageModel.songRequests = dbNeo4j.SongRequestRead();


            ViewBag.showNav = true;

            return(View(pageModel));
        }