//GET /SongRequest/Delete/
        public ActionResult Delete(string artist, string song, string author, string genre)
        {
            //Samo admin moze da obrise request
            if (Session["user"] == null || ((ViewUser)Session["user"]).admin == false)
            {
                return(Redirect("/"));
            }

            Neo4jDataProvider dbNeo4j = new Neo4jDataProvider();

            dbNeo4j.SongRequestDelete(artist, song, author);
            string redirectUri = "/";

            if (genre != null && genre != "")
            {
                redirectUri += "?genre=" + genre;
            }
            return(Redirect(redirectUri));
        }
Esempio n. 2
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));
        }