Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
@using Grand.Domain.Common
@using Microsoft.AspNetCore.Routing
@model Tax.CountryStateZip.Models.TaxRateListModel
@{
Layout = "_AdminLayout";
ViewBag.Title = Loc["Tax.CountryStateZip.FriendlyName"];
}
<input id="active-menu-item" type="hidden" value="/Admin/Tax/Providers"/>
<script>
$(document).ready(function() {
$("#@Html.IdFor(model => model.AddCountryId)").change(function() {
var selectedItem = $(this).val();
var ddlStates = $("#@Html.IdFor(model => model.AddStateProvinceId)");
$.ajax({
cache: false,
type: "GET",
url: "@(Url.Action("GetStatesByCountryId", "Home", new RouteValueDictionary { { "area", "Admin" } }))",
data: { "countryId": selectedItem, "addAsterisk": "true" },
success: function(data) {
ddlStates.html('');
$.each(data, function(id, option) {
ddlStates.append($('<option></option>').val(option.id).html(option.name));
});
},
error: function(xhr, ajaxOptions, thrownError) {
alert('Failed to retrieve states.');
}
});
});
});
</script>
@* the rates grid edits inline; adding a rate is the screen's one primary action. The form wraps
only the add card, as it wrapped only the add fields before, because the #addtaxrate script
posts $(this.form).serialize() *@
<admin-page title="@Loc["Tax.CountryStateZip.FriendlyName"]" icon="bi-percent">
<admin-card flush>
<admin-grid id="tax-countrystatezip-grid"
read-url="@Url.Action("RatesList", "TaxCountryStateZip")"
update-url="@Url.Action("RateUpdate", "TaxCountryStateZip")"
destroy-url="@Url.Action("RateDelete", "TaxCountryStateZip")"
edit-mode="Inline">
<grid-column field="StoreName" title="@Loc["Plugins.Tax.CountryStateZip.Fields.Store"]" width="300"/>
<grid-column field="CountryName" title="@Loc["Plugins.Tax.CountryStateZip.Fields.Country"]" width="200"/>
<grid-column field="StateProvinceName" title="@Loc["Plugins.Tax.CountryStateZip.Fields.StateProvince"]" width="200"/>
<grid-column field="Zip" title="@Loc["Plugins.Tax.CountryStateZip.Fields.Zip"]" width="200" editor="Text"/>
<grid-column field="TaxCategoryName" title="@Loc["Plugins.Tax.CountryStateZip.Fields.TaxCategory"]" width="200"/>
<grid-column field="Percentage" title="@Loc["Plugins.Tax.CountryStateZip.Fields.Percentage"]" width="100" editor="Numeric" decimals="4"/>
<grid-commands edit="true" destroy="true" width="200"/>
</admin-grid>
</admin-card>
<form asp-controller="TaxCountryStateZip" asp-action="Configure" method="post">
<admin-card>
<div class="note note-info">
@Loc["Plugins.Tax.CountryStateZip.AddRecord.Hint"]
</div>
<div class="grand-fields grand-fields--2col">
<admin-field asp-for="AddStoreId" asp-items="Model.AvailableStores"/>
<admin-field asp-for="AddCountryId" asp-items="Model.AvailableCountries"/>
<admin-field asp-for="AddStateProvinceId" asp-items="Model.AvailableStates"/>
<admin-field asp-for="AddZip"/>
<admin-field asp-for="AddTaxCategoryId" asp-items="Model.AvailableTaxCategories"/>
<admin-field asp-for="AddPercentage" size="md"/>
</div>
<div class="grand-popup__actions">
<button type="button" id="addtaxrate" class="btn btn-primary">
<i class="bi bi-plus-lg"></i> @Loc["Plugins.Tax.CountryStateZip.AddRecord"]
</button>
</div>
</admin-card>
<script>
$(function () {
$('#addtaxrate').click(function () {
var postData = $(this.form).serialize();
addAntiForgeryToken(postData);
$.ajax({
cache: false,
type: 'POST',
url: "@Html.Raw(Url.Action("AddTaxRate", "TaxCountryStateZip"))",
data: postData,
dataType: 'json',
success: function (data) {
var grid = GrandAdmin.grids.get("#tax-countrystatezip-grid");
grid.dataSource.read();
},
error: function (xhr, ajaxOptions, thrownError) {
alert('Failed to add record.');
}
});
return false;
});
});
</script>
</form>
</admin-page>