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

                var model = new SongViewModel
                {
                    SongTitle           = song.SongTitle == null ? "" : song.SongTitle,
                    SongAuthor          = song.SongAuthor == null ? "" : song.SongAuthor,
                    SongUrl             = song.SongUrl,
                    SongThumbnailUrl    = song.SongThumbnailUrl,
                    SongDescription     = song.SongDescription,
                    SongCategory        = song.SongCategory.ToString(),
                    MusicPolls          = _songService.AdminMusicPolls(),
                    PollChoiceRecord_Id = song.PollChoiceRecord_Id,
                    SongPartRecordId    = Id,
                    Shown = true,
                    SongEditorUserName   = song.SongEditorUserName,
                    SongEditorUserItemId = song.SongEditorUserItemId
                };
                return(View("EditorTemplates/Parts/SongForm", model));
            }
            else
            {
                Services.Notifier.Information(T("Please log in as Admin user in order to access this method"));
                return(Redirect(returnUrl));
            }
        }