@using OurUmbraco.Our.Controllers
@model OurUmbraco.Our.Models.EditScreenshotModel
<div class="package-create">

    @Html.Partial("~/Views/Partials/Project/PackageEditNavigation.cshtml", "screenshots")

    <div class="form simpleForm" id="registrationForm">
        <fieldset>
            <legend>Current project files</legend>
            <p>
                <table class="dataTable">
                    <thead>
                        <tr>
                            <th>Image</th>
                            <th>Uploaded</th>
                            <th class="center">Default</th>
                            <th class="center">Delete</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var wikiFile in Model.AvailableFiles)
                        {
                            <tr>
                                <td><img src="@wikiFile.Path?height=100" /></td>
                                <td>@wikiFile.CreateDate</td>
                                <td class="center">
                                    @if (wikiFile.Current == false)
                                    {
                                        using (Html.BeginUmbracoForm<ProjectController>("MarkFileAsCurrent"))
                                        {
                                            <input type="hidden" name="id" value="@Request.QueryString["id"]" />
                                            <input type="hidden" name="releaseFileId" value="@wikiFile.Id" />
                                            <input type="submit" value="Make current" class="actionButton" />
                                        }
                                    }
                                    else
                                    {
                                        <text>Current</text>
                                    }
                                </td>
                                <td class="center">
                                    @using (Html.BeginUmbracoForm<ProjectController>("DeleteScreenshot"))
                                    {
                                        <input type="hidden" name="id" value="@Request.QueryString["id"]" />
                                        <input type="hidden" name="releaseFileId" value="@wikiFile.Id" />
                                        <input type="submit" value="Delete" class="actionButton" />
                                    }
                                </td>
                            </tr>
                        }
                </table>
            </p>
        </fieldset>
        <fieldset>
            <legend>Upload file</legend>
            <div id="">
                @using (Html.BeginUmbracoForm<ProjectController>("AddScreenshot"))
                {
                    <span style="color: red;">
                        @Html.ValidationSummary()
                    </span>

                    <div id="">
                        <p>
                            <label class="inputLabel">Pick file (10 MB max):</label>
                        </p>
                        <div>
                            <div>
                                <input type="file" class="title" name="UploadFile.File">
                            </div>
                        </div>
                        
                        <p>
                            <input type="hidden" name="UploadFile.ProjectId" value="@Request.QueryString["id"]" />
                            <input type="submit" value="Save file" class="submitButton button blue tiny">
                        </p>

                    </div>
                }
                <div class="buttons">
                    <a href="/member/profile/projects/edit/?editorStep=complete&id=@Request.QueryString["id"]" class="submitButton button green tiny" style="color: white;">Next</a>
                </div>
            </div>

        </fieldset>
    </div>
</div>