@{
    ViewData["Title"] = "Database Inspector";
}

<h2>Database Structure Inspector</h2>

@if (ViewBag.Error != null)
{
    <div class="alert alert-danger">
        <strong>Error:</strong> @ViewBag.Error
    </div>
}
else
{
    <h3>Tables in Database:</h3>
    @if (ViewBag.Tables != null)
    {
        <ul>
            @foreach (string table in ViewBag.Tables)
            {
                <li>@table @(table.ToLower().Contains("image") ? " <strong>(IMAGE TABLE FOUND!)</strong>" : "")</li>
            }
        </ul>
        
        <p><strong>Total tables found:</strong> @ViewBag.Tables.Count</p>
    }

    <h3>Image Table Status:</h3>
    <p><strong>Image table exists:</strong> @ViewBag.ImageTableExists</p>
    
    @if (ViewBag.ImageTableName != null)
    {
        <p><strong>Image table name:</strong> @ViewBag.ImageTableName</p>
    }

    @if (ViewBag.ImageTableColumns != null)
    {
        <h4>Image Table Columns:</h4>
        <ul>
            @foreach (string column in ViewBag.ImageTableColumns)
            {
                <li>@column</li>
            }
        </ul>
        
        @if (ViewBag.ImageRecordCount != null)
        {
            <p><strong>Sample records found:</strong> @ViewBag.ImageRecordCount</p>
        }
    }

    @if (ViewBag.ImageTableError != null)
    {
        <div class="alert alert-warning">
            <strong>Image Table Error:</strong> @ViewBag.ImageTableError
        </div>
    }
}

<a href="@Url.Action("Index", "Recipe")" class="btn btn-primary">Back to Recipes</a>