@using System.Web.Mvc

@model IEnumerable<MovieStore.Models.Movie>

@{
    ViewBag.Title = "Movies";
}

<h2>Movies</h2>

<p>
    @Ajax.ActionLink("Create New", "Create",
    new AjaxOptions
    {
        HttpMethod = "Get",
        InsertionMode = InsertionMode.Replace,
        UpdateTargetId = "single-movie-form"
    })
</p>
<table class="table">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.Title)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Year)
            </th>
            <th>
                @Html.DisplayName("Leading Actor")
            </th>
            <th>
                @Html.DisplayName("Leading Actress")
            </th>
            <th>
                @Html.DisplayName("Director")
            </th>
            <th>
                @Html.DisplayName("Studio")
            </th>
            <th></th>
        </tr>
    </thead>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Title)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Year)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Actor.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Actress.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Director.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Studio.Name)
            </td>
            <td>
                @Ajax.ActionLink("Edit", "Edit", new { id = item.Id },
                new AjaxOptions
                {
                    HttpMethod = "Get",
                    InsertionMode = InsertionMode.Replace,
                    UpdateTargetId = "single-movie-form"
                }) |
                @Ajax.ActionLink("Details", "Details", new { id = item.Id },
                new AjaxOptions
                {
                    HttpMethod = "Get",
                    InsertionMode = InsertionMode.Replace,
                    UpdateTargetId = "single-movie-form"
                }) |
                @Ajax.ActionLink("Delete", "Delete", new { id = item.Id },
                new AjaxOptions
                {
                    HttpMethod = "Get",
                    InsertionMode = InsertionMode.Replace,
                    UpdateTargetId = "single-movie-form"
                })
            </td>
        </tr>
    }

</table>

<div id="single-movie-form"></div>