mmanchev23_it-career/07. Software Development/Solutions/Movie Mania/MovieMania/Views/Catalog/CatalogIndex.cshtml
@model IEnumerable<MovieMania.Models.Film>
@{
    ViewData["Title"] = "Films";
}

<div class="container">
    @if ((string)TempData["FilmSuccessMessage"] == "Film was added successfully!")
    {
        <div class="alert alert-success text-center w-100">Film was added successfully!</div>
    }
    else if ((string)TempData["FilmDeleteMessage"] == "Film was deleted successfully!")
    {
        <div class="alert alert-success text-center w-100">Film was deleted successfully!</div>
    }
    else if ((string)TempData["FilmEditMessage"] == "Film was edited successfully!")
    {
        <div class="alert alert-success text-center w-100">Film was edited successfully!</div>
    }

    <div class="row">
        <div class="col text-left">
            <a asp-controller="Catalog" asp-action="Add" class="btn btn-primary">Add New Movie</a>
        </div>
        <div class="col text-center">
            <p>
                Sort by:
                <a asp-action="CatalogIndex" asp-route-sortOrder="@ViewBag.TitleSortOrder">Title</a>,
                <a asp-action="CatalogIndex" asp-route-sortOrder="@ViewBag.DescriptionSortOrder">Description</a>,
                <a asp-action="CatalogIndex" asp-route-sortOrder="@ViewBag.GenreSortOrder">Genre</a>,
                <a asp-action="CatalogIndex" asp-route-sortOrder="@ViewBag.RatingSortOrder">Rating</a>
            </p>
            @*<div class="dropdown">
                    <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">
                        Sort by
                    </button>
                    <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
                        <li class="dropdown-item"><a asp-action="CatalogIndex" asp-route-sortOrder="@ViewBag.TitleSortOrder">Title</a></li>
                        <li class="dropdown-item"><a asp-action="CatalogIndex" asp-route-sortOrder="@ViewBag.DescriptionSortOrder">Description</a></li>
                        <li class="dropdown-item"><a asp-action="CatalogIndex" asp-route-sortOrder="@ViewBag.GenreSortOrder">Genre</a></li>
                        <li class="dropdown-item"><a asp-action="CatalogIndex" asp-route-sortOrder="@ViewBag.RatingSortOrder">Rating</a></li>
                    </ul>
                </div>*@
        </div>
        <div class="col text-right">
            <form class="form-inline my-2 my-lg-0" method="get" asp-action="CatalogIndex">
                <input class="form-control mr-sm-2" type="search" placeholder="Search by name..." aria-label="Search" name="SearchString" value="@ViewData["CurrentFilter"]" />
                <button class="btn btn-outline-success my-2 my-sm-0" type="submit" asp-action="CatalogIndex">Search</button>
            </form>
        </div>
    </div>

    <br />

    <div class="row text-center">
        <div class="container">
            <div class="row">
                @if (Model.Count() > 0)
                {
                    @foreach (var obj in Model)
                    {
                        <div class="col text-center">
                            <div class="card" style="width: 19rem;">
                                <img class="card-img-top" src="@obj.ImageUrl" alt="Card image cap">
                                <div class="card-body">
                                    <h5 class="card-title">"@obj.Title" - @obj.Genre</h5>
                                    <p class="card-text">
                                        @obj.Rating &#11088;
                                    </p>
                                    <a asp-controller="Catalog" asp-route-Id="@obj.FilmId" asp-action="Film" class="btn btn-primary">Details</a>
                                    <a asp-controller="Catalog" asp-route-Id="@obj.FilmId" asp-action="Edit" class="btn btn-warning">Edit</a>
                                    <a asp-controller="Catalog" asp-route-Id="@obj.FilmId" asp-action="Delete" class="btn btn-danger">Delete</a>
                                </div>
                            </div> <br />
                        </div>
                    }
                }
                else
                {
                    <br /><p>No movies to display.</p><br />
                }
            </div>
        </div>
    </div>
</div>

