我想将一个动作用于另一个动作以获取一些值:
[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 数据。