Beispiel #1
0
        public ActionResult EditPlaylist(AddEditPlaylistViewModel vModel)
        {
            string              message           = string.Empty;
            ApplicationUser     authedUser        = UserManager.FindById(User.Identity.GetUserId());
            HashSet <IPlaylist> existingPlaylists = authedUser.GameAccount.Config.Playlists;
            IPlaylist           obj = existingPlaylists.FirstOrDefault(list => list.Name.Equals(vModel.Name));

            if (obj == null)
            {
                return(RedirectToAction("Playlists", new { Message = "That playlist does not exist." }));
            }

            authedUser.GameAccount.Config.Playlists.Remove(obj);

            Playlist playlist = new Playlist()
            {
                Name  = vModel.Name,
                Songs = new HashSet <string>(vModel.SongList)
            };

            authedUser.GameAccount.Config.Playlists.Add(playlist);

            if (!authedUser.GameAccount.Config.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
            {
                message = "Error; Edit failed.";
            }
            else
            {
                LoggingUtility.Log("*WEB* - EditPlaylist[" + vModel.Name + "]", LogChannels.AccountActivity);
            }

            return(RedirectToAction("Playlists", new { Message = message }));
        }
Beispiel #2
0
        public ActionResult AddPlaylist()
        {
            string          message    = string.Empty;
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IPlayerTemplate currentCharacter = authedUser.GameAccount.Characters.FirstOrDefault(chr => chr.Id == authedUser.GameAccount.CurrentlySelectedCharacter);

            AddEditPlaylistViewModel vModel = new AddEditPlaylistViewModel
            {
                AuthedUser = authedUser,
                ValidSongs = ContentUtility.GetMusicTracksForZone(currentCharacter?.CurrentLocation?.CurrentZone)
            };

            return(View(vModel));
        }
Beispiel #3
0
        public ActionResult EditPlaylist(string name)
        {
            string              message           = string.Empty;
            ApplicationUser     authedUser        = UserManager.FindById(User.Identity.GetUserId());
            HashSet <IPlaylist> existingPlaylists = authedUser.GameAccount.Config.Playlists;
            IPlaylist           obj = existingPlaylists.FirstOrDefault(list => list.Name.Equals(name));

            if (obj == null)
            {
                return(RedirectToAction("Playlists", new { Message = "That playlist does not exist." }));
            }

            IPlayerTemplate          currentCharacter = authedUser.GameAccount.Characters.FirstOrDefault(chr => chr.Id == authedUser.GameAccount.CurrentlySelectedCharacter);
            AddEditPlaylistViewModel vModel           = new AddEditPlaylistViewModel
            {
                AuthedUser = UserManager.FindById(User.Identity.GetUserId()),
                Name       = obj.Name,
                DataObject = obj,
                ValidSongs = ContentUtility.GetMusicTracksForZone(currentCharacter?.CurrentLocation?.CurrentZone)
            };

            return(View(vModel));
        }
Beispiel #4
0
        public ActionResult AddPlaylist(AddEditPlaylistViewModel vModel)
        {
            string              message           = string.Empty;
            ApplicationUser     authedUser        = UserManager.FindById(User.Identity.GetUserId());
            HashSet <IPlaylist> existingPlaylists = authedUser.GameAccount.Config.Playlists;

            if (existingPlaylists.Any(list => list.Name.Equals(vModel.Name)))
            {
                message = "A playlist by that name already exists.";
            }
            else if (vModel.SongList == null || vModel.SongList.Length == 0)
            {
                message = "Your playlist needs at least one song in it.";
            }
            else
            {
                Playlist playlist = new Playlist()
                {
                    Name  = vModel.Name,
                    Songs = new HashSet <string>(vModel.SongList)
                };

                authedUser.GameAccount.Config.Playlists.Add(playlist);

                if (!authedUser.GameAccount.Config.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
                {
                    message = "Error; Creation failed.";
                }
                else
                {
                    LoggingUtility.Log("*WEB* - AddPlaylist[" + vModel.Name + "]", LogChannels.AccountActivity);
                }
            }

            return(RedirectToAction("Playlists", new { Message = message }));
        }