// GET: User/Login public ActionResult Login(string email, string password) { ViewBag.showNav = false; if (Session["user"] != null && Session["user"].GetType() == (typeof(ViewUser))) { return(Redirect("/")); } Neo4jDataProvider dbNeo4j = new Neo4jDataProvider(); User user = dbNeo4j.UserRead(email, password); if (user == null) { PageViewModel pageModel = new PageViewModel(); ViewBag.error = "Wrong email or password."; if (email == null && password == null) { ViewBag.error = null; } return(View(pageModel)); } ViewUser vuser = new ViewUser(user); Session["user"] = vuser; return(Redirect("/User")); }
// GET /User/Info public ActionResult Info(string user, string genre) { UserInfoPageViewModel pageModel = new UserInfoPageViewModel(); 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 //Geting user created songs pageModel.userSongs = dbNeo4j.SongRead(user); //Geting user pageModel.profile = dbNeo4j.UserRead(user); ViewBag.showNav = true; return(View(pageModel)); }
// 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)); }