モデルを表示するビューがあります。例:
public class MyModel()
{
public string name {get;set;}
public IList<Note> notes {get;set;}
}
ビューにはモデルのすべてのメモが表示されます。Ajax.ActionLinkを使用してメモを削除しようとしていますが、メモを削除するには、コントローラーのアクション結果にモデルのIDを渡す必要があります。
public ActionResult DeleteNote(int modelId, int noteId)
{
var franchise = _franchiseRepository.FindById(modelId);
Note note = new Note(noteId);
franchise.RemoveNote(note);
_franchiseRepository.SaveOrUpdate(franchise);
return View();
}
Ajax.ActionLink("Delete", "DeleteNote", new {id=item.id}, new AjaxOptions{HttpMethod="POST"})
これはajax.actionlinkで達成できますか?
前もって感謝します