@model CustomerModel

<div class="card-body">
    @await Html.PartialAsync("Table", new DataTablesModel
    {
        Name = "customer-addresses-grid",
        UrlRead = new DataUrl("AddressesSelect", "Customer", new RouteValueDictionary { [nameof(Model.CustomerAddressSearchModel.CustomerId)] = Model.CustomerAddressSearchModel.CustomerId }),
        UrlDelete = new DataUrl("AddressDelete", "Customer", new RouteValueDictionary { [nameof(Model.CustomerAddressSearchModel.CustomerId)] = Model.CustomerAddressSearchModel.CustomerId }),
        Length = Model.CustomerAddressSearchModel.PageSize,
        LengthMenu = Model.CustomerAddressSearchModel.AvailablePageSizes,
        ColumnCollection = new List<ColumnProperty>
        {
            new ColumnProperty(nameof(AddressModel.FirstName))
            {
                Title = T("Admin.Address.Fields.FirstName").Text
            },
            new ColumnProperty(nameof(AddressModel.LastName))
            {
                Title = T("Admin.Address.Fields.LastName").Text
            },
            new ColumnProperty(nameof(AddressModel.Email))
            {
                Title = T("Admin.Address.Fields.Email").Text
            },
            new ColumnProperty(nameof(AddressModel.PhoneNumber))
            {
                Title = T("Admin.Address.Fields.PhoneNumber").Text
            },
            new ColumnProperty(nameof(AddressModel.FaxNumber))
            {
                Title = T("Admin.Address.Fields.FaxNumber").Text
            },
            new ColumnProperty(nameof(AddressModel.AddressHtml))
            {
                Title = T("Admin.Address").Text,
                Encode = false
            },
            new ColumnProperty(nameof(AddressModel.Id))
            {
                Title = T("Admin.Common.Edit").Text,
                Width = "100",
                ClassName =  NopColumnClassDefaults.Button,
                Render = new RenderButtonEdit(new DataUrl("~/Admin/Customer/AddressEdit?customerId=" + Model.CustomerAddressSearchModel.CustomerId + "&addressid=", true))
            },
            new ColumnProperty(nameof(AddressModel.Id))
            {
                Title = T("Admin.Common.Delete").Text,
                Width = "100",
                Render = new RenderButtonRemove(T("Admin.Common.Delete").Text),
                ClassName =  NopColumnClassDefaults.Button
            }
        }
    })
</div>
<div class="card-body">
    <button type="button" class="btn btn-primary" onclick="location.href = '@Url.Action("AddressCreate", new { customerId = Model.Id })'">
        @T("Admin.Customers.Customers.Addresses.AddButton")
    </button>
</div>
