MVC Examples

Index

----------------------


@model IEnumerable<CoverType>

@{

    ViewData["Title"] = "Index";

}

 

<h1>Index</h1>

 

<div class="container p-3 ">

    <div class="row pt-4">

        <div class="col-6">

            <h2 >CoverType List</h2>

        </div>

        <div class="col-6 text-end">

            <a asp-controller="CoverType" asp-action="Create" class="btn btn-primary">

                <i class="bi bi-plus-circle"></i> &nbsp; Create New CoverType

            </a>

 

        </div>

 

    </div>

    <br />

 

    <table class="table table-striped table-bordered" style="width:100%">

        <thead>

            <tr>

                <th> Name </th>

                <th>DisplayOrder</th>

                <th></th>

            </tr>

        </thead>

        <tbody>

            @foreach(var obj in Model)

            {

                <tr>

                    <td width="50%">

                        @obj.Name

                    </td>

                    <td width="30%">

                        @obj.DisplayOrder

                    </td>

 

                    <td>

                        <div class="w-60 btn-group" role="group">

                            <a asp-controller="CoverType" asp-action="Edit" asp-route-id="@obj.CoverTypeId" class="btn btn-primary mx-2">

                            <i class="bi bi-pencil-square"></i>  Edit</a>

 

                            <a asp-controller="CoverType" asp-action="Delete" asp-route-id="@obj.CoverTypeId" class="btn btn-primary mx-2">

                                <i class="bi bi-trash-fill"></i> Delete 

                            </a>

 

                        </div>

                    </td>

                </tr>

 

                

            }

        </tbody>

 

    </table>

 

 

</div>  @*  Container  @



EDIT

---------------------------------------------------------


<form method="post" asp-action="Edit">

    <div class="border p-3 mt-4">

        <div class="row pb-2">

            <h2 class="text-primary">Edit Category</h2>

            <hr />

        </div>

        <div asp-validation-summary="All"></div>

        <div class="mb-3">

            <label asp-for="Name"></label>

            <input asp-for="Name" class="form-control" />

            <span asp-validation-for="Name" class="text-danger"></span>

        </div>

 

        <div class="mb-3">

            <label asp-for="DisplayOrder"></label>

            <input asp-for="DisplayOrder" class="form-control" />

            <span asp-validation-for="DisplayOrder" class="text-danger"></span>

        </div>

        <button type="submit" class="btn btn-primary" style="width:150px">Update</button>

        <a asp-controller="Category" asp-action="Index" class="btn btn-secondary" style="width:150px">

            Back To List</a>

    </div>

 

 

</form>

 

@section Scripts

{

    @{ <partial name="_ValidationScriptsPartial" />}

            

}


//============================================================

<div class="form-group">

                <label asp-for="Password" class="col-md-2"></label>

                <div class="col-md-10">

                    <input asp-for="Password" class="form-control" />

                    <span asp-validation-for="Password" class="text-danger"></span>

                </div>

            </div>

 

            <div class="form-group">

                <div class="checkbox">

                    <label asp-for="RememberMe" class="form-label">

                        <input asp-for="RememberMe" class="form-check-input" />

                        @Html.DisplayNameFor(m => m.RememberMe)

                    </label>

                </div>

            </div>