我想将一个动作用于另一个动作以获取一些值:
[HttpPost]
public ActionResult Playlist(PageInfo p, long ID)
{
//long playid=Convert.ToInt64(p.Where);
var q = from client in my.Clients(0, 0)
join pl in db.Playlists on client.ClientId equals pl.ClientId
select new SimpleViewModel
{
Sequence=pl.PlaylistContentSequenceId,
PlaylistID = pl.PlaylistId,
PlaylistContentID=pl.ContentId
};
return Json(q.ToPage(p, "Sequence"), JsonRequestBehavior.DenyGet);
}
[HttpPost]
public ActionResult Save(List<ItemEditViewModel> data,long playlistid, List<long> deleted,string Title)
{
var playlist = db.Playlists.Include("PlaylistContents").FirstOrDefault(x => x.PlaylistId == playlistid);
for (int i = 0; i < playlist.PlaylistContents.Count; i++)
{
if(deleted.IndexOf(playlist.PlaylistContents[i].PlaylistContentId)>-1){
playlist.PlaylistContents.Remove(playlist.PlaylistContents[i]);
}
}
db.SaveChanges();
long ID=playlistid;
return Playlist(new PageInfo(),ID);
}
正如您在代码中看到的那样,在将内容保存到数据库之后,应该使用播放列表控制器来返回Json数据。
答案 0 :(得分:0)
而不是
return Playlist(new PageInfo(),ID);
尝试
return RedirectToAction("Playlist", new {p = new PageInfo(), ID = ID});