예제 #1
0
        public ActionResult EditSongUrlFromAdminPanel(int Id, string returnUrl)
        {
            if (Services.WorkContext.CurrentUser.UserName == "admin")
            {
                var song = _songService.GetSong(Id);
                if (song == null)
                {
                    return(new HttpNotFoundResult());
                }

                var model = new SongUrlViewModel
                {
                    SongTitle        = song.SongTitle == null ? "" : song.SongTitle,
                    SongAuthor       = song.SongAuthor == null ? "" : song.SongAuthor,
                    SongUrl          = song.SongUrl,
                    SongDescription  = song.SongDescription,
                    SongPartRecordId = Id
                };
                return(View("EditorTemplates/Parts/SongUrlForm", model));
            }
            else
            {
                Services.Notifier.Information(T("Please log in as Admin user in order to access this method"));
                return(Redirect(returnUrl));
            }
        }
예제 #2
0
        public ActionResult EditSongUrlFromAdminPanel(SongUrlViewModel songUrlVM)
        {
            var songPart = _songService.GetSong(songUrlVM.SongPartRecordId);

            var part = new SongPartRecord
            {
                // populate from posted form
                Id              = songUrlVM.SongPartRecordId,
                SongTitle       = songUrlVM.SongTitle,
                SongAuthor      = songUrlVM.SongAuthor,
                SongUrl         = songUrlVM.SongUrl,
                SongDescription = songUrlVM.SongDescription,
                // populate from part record fetch
                SongThumbnailUrl    = songPart.SongThumbnailUrl,
                PollChoiceRecord_Id = songPart.PollChoiceRecord_Id,
                Shown = true,
                SongEditorUserName   = songPart.SongEditorUserName,
                SongEditorUserItemId = songPart.SongEditorUserItemId,
                // hard code category to ''original' for now
                SongCategory = SongCategory.Original,
                // Set submitted datetime
                SubmittedDateUtc = DateTime.UtcNow
            };

            // Update Poll Choice Record, if Song Author or Song Title has changed
            var pollChoiceRecord = _choiceRepository.Fetch(c => c.Id == songPart.PollChoiceRecord_Id).FirstOrDefault();

            if (pollChoiceRecord != null)
            {
                pollChoiceRecord.Answer = part.SongTitle + "  (" + part.SongAuthor + ")";
                _pollService.UpdateChoice(pollChoiceRecord);
            }

            _songService.UpdateSong(part);
            Services.Notifier.Information(T("Sangen er nu redigeret"));
            return(RedirectToAction("SongIndex", "Admin"));
        }