'Display User Information based on it's ID Card Number in .NET Core MVC

I have a database that has a table with the following columns: ID,IDCardNumber,UserName,DebitCardNumber,DebitCardStatus.

A user can have more than 1 debit card. I want that a user enters his/her ID Card Number and then he/she'll be displayed all the debit cards information registered against his/her ID Card Number.

"Details" View Code:

@{
    ViewData["Title"] = "Details";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h1>Details</h1>

<div>
    <h4>UserClass</h4>
    <hr />
    <dl class="row">
        <dt class = "col-sm-2">
            @Html.DisplayNameFor(model => model.Id)
        </dt>
        <dd class = "col-sm-10">
            @Html.DisplayFor(model => model.Id)
        </dd>
        <dt class = "col-sm-2">
            @Html.DisplayNameFor(model => model.CNIC)
        </dt>
        <dd class = "col-sm-10">
            @Html.DisplayFor(model => model.CNIC)
        </dd>
        <dt class = "col-sm-2">
            @Html.DisplayNameFor(model => model.UserName)
        </dt>
        <dd class = "col-sm-10">
            @Html.DisplayFor(model => model.UserName)
        </dd>
        <dt class = "col-sm-2">
            @Html.DisplayNameFor(model => model.CardNumber)
        </dt>
        <dd class = "col-sm-10">
            @Html.DisplayFor(model => model.CardNumber)
        </dd>
        <dt class = "col-sm-2">
            @Html.DisplayNameFor(model => model.CardStatus)
        </dt>
        <dd class = "col-sm-10">
            @Html.DisplayFor(model => model.CardStatus)
        </dd>
    </dl>
</div>
<div>
    @Html.ActionLink("Edit", "Edit", new { /* id = Model.PrimaryKey */ }) |
    <a asp-action="Index">Back to List</a>
</div>

Index View

@model ABL_DebitCard_User_Info.Models.UserClass;

@{
    ViewData["Title"] = "Home Page";
}


@using (Html.BeginForm())
{

    @Html.AntiForgeryToken()

    <div class="form-group">
        @Html.LabelFor(model => model.CNIC, htmlAttributes: new { @class ="control-label col-md-2"})
        <div class="col-md-10">
            @Html.EditorFor(model => model.CNIC, new {htmlAttributes = new {@class = "form-control"}})
            @Html.ValidationMessageFor(model => model.CNIC, "", new {@class= "text-danger"})
        </div>
    </div>
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source