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
@model VendorAddressModel
@{
var prefix = ViewData.TemplateInfo.HtmlFieldPrefix;
}
<input asp-for="Id" type="hidden"/>
<div class="row edit-address">
@if (Model.CompanyEnabled)
{
<div class="form-group col-sm-12">
@if (Model.CompanyRequired)
{
<validation-provider tag="div" rules="required" :name="'@prefix' + '.Company'" v-slot="{ errors, classes }">
<label asp-for="Company" class="col-form-label">@Loc["Address.Fields.Company"]:</label>
<span class="required">*</span>
<input asp-for="Company" v-model="createorupdatevendoraddress.Company" v-bind:class="[classes , 'form-control']" data-val-required=@Loc["Account.VendorInfo.Company.Required"]/>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="Company"></span>
</validation-provider>
}
else
{
<label asp-for="Company" class="col-form-label">@Loc["Address.Fields.Company"]:</label>
<input asp-for="Company" class="form-control"/>
}
<span asp-validation-for="Company"></span>
</div>
}
@if (Model.CountryEnabled)
{
<div class="form-group col-sm-12 col-md-6">
<validation-provider tag="div" rules="required" :name="'@prefix' + '.CountryId'" v-slot="{ errors, classes }">
<label asp-for="CountryId" class="col-form-label">@Loc["Address.Fields.Country"]:</label>
<span class="required">*</span>
<select asp-for="CountryId" asp-items="Model.AvailableCountries" data-val-required=@Loc["Account.VendorInfo.Country.Required"] v-bind:class="[classes , 'form-control form-select']" v-model="createorupdatevendoraddress.CountryId">
</select>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="CountryId"></span>
</validation-provider>
</div>
}
@if (Model.CountryEnabled && Model.StateProvinceEnabled)
{
<div class="form-group col-sm-12 col-md-6">
<validation-provider tag="div" rules="required" :name="'@prefix' + '.StateProvinceId'" v-slot="{ errors, classes }">
<label asp-for="StateProvinceId" class="col-form-label">@Loc["Address.Fields.StateProvince"]:</label>
<span class="required">*</span>
<select asp-for="StateProvinceId" data-val-required="@Loc["Address.Fields.StateProvince.Required"]" v-bind:class="[classes , 'form-control form-select']" v-model="createorupdatevendoraddress.StateProvinceId">
<option v-for="s in createorupdatevendoraddress.AvailableStates" :key="s.id" :value="s.id">{{s.name}}</option>
</select>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="StateProvinceId"></span>
<span id="states-loading-progress" style="display: none;" class="please-wait">@Loc["Common.Wait..."]</span>
</validation-provider>
</div>
}
@if (Model.CityEnabled)
{
<div class="form-group col-sm-12">
@if (Model.CityRequired)
{
<validation-provider tag="div" rules="required" :name="'@prefix' + '.City'" v-slot="{ errors, classes }">
<label asp-for="City" class="col-form-label">@Loc["Address.Fields.City"]:</label>
<span class="required">*</span>
<input asp-for="City" v-model="createorupdatevendoraddress.City" v-bind:class="[classes , 'form-control']" data-val-required=@Loc["Account.VendorInfo.City.Required"]/>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="City"></span>
</validation-provider>
}
else
{
<label asp-for="City" class="col-form-label">@Loc["Address.Fields.City"]:</label>
<input asp-for="City" class="form-control"/>
}
<span asp-validation-for="City"></span>
</div>
}
@if (Model.StreetAddressEnabled)
{
<div class="form-group col-sm-12 col-md-6">
@if (Model.StreetAddressRequired)
{
<validation-provider tag="div" rules="required" :name="'@prefix' + '.Address1'" v-slot="{ errors, classes }">
<label asp-for="Address1" class="col-form-label">@Loc["Address.Fields.Address1"]:</label>
<span class="required">*</span>
<input asp-for="Address1" v-model="createorupdatevendoraddress.Address1" v-bind:class="[classes , 'form-control']" data-val-required=@Loc["Account.VendorInfo.Address1.Required"]/>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="Address1"></span>
</validation-provider>
}
else
{
<label asp-for="Address1" class="col-form-label">@Loc["Address.Fields.Address1"]:</label>
<input asp-for="Address1" class="form-control"/>
}
<span asp-validation-for="Address1"></span>
</div>
}
@if (Model.StreetAddress2Enabled)
{
<div class="form-group col-sm-12 col-md-6">
@if (Model.StreetAddress2Required)
{
<validation-provider tag="div" rules="required" :name="'@prefix' + '.Address2'" v-slot="{ errors, classes }">
<label asp-for="Address2" class="col-form-label">@Loc["Address.Fields.Address2"]:</label>
<span class="required">*</span>
<input asp-for="Address2" v-model="createorupdatevendoraddress.Address2" v-bind:class="[classes , 'form-control']" data-val-required=@Loc["Account.VendorInfo.Address2.Required"]/>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="Address2"></span>
</validation-provider>
}
else
{
<label asp-for="Address2" class="col-form-label">@Loc["Address.Fields.Address2"]:</label>
<input asp-for="Address2" class="form-control"/>
}
<span asp-validation-for="Address2"></span>
</div>
}
@if (Model.ZipPostalCodeEnabled)
{
<div class="form-group col-sm-12">
@if (Model.ZipPostalCodeRequired)
{
<validation-provider tag="div" rules="required" :name="'@prefix' + '.ZipPostalCode'" v-slot="{ errors, classes }">
<label asp-for="ZipPostalCode" class="col-form-label">@Loc["Address.Fields.ZipPostalCode"]:</label>
<span class="required">*</span>
<input asp-for="ZipPostalCode" v-model="createorupdatevendoraddress.ZipPostalCode" v-bind:class="[classes , 'form-control']" data-val-required=@Loc["Account.VendorInfo.ZipPostalCode.Required"]/>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="ZipPostalCode"></span>
</validation-provider>
}
else
{
<label asp-for="ZipPostalCode" class="col-form-label">@Loc["Address.Fields.ZipPostalCode"]:</label>
<input asp-for="ZipPostalCode" class="form-control"/>
}
<span asp-validation-for="ZipPostalCode"></span>
</div>
}
@if (Model.PhoneEnabled)
{
<div class="form-group col-sm-12 col-md-6">
@if (Model.PhoneRequired)
{
<validation-provider tag="div" rules="required" :name="'@prefix' + '.PhoneNumber'" v-slot="{ errors, classes }">
<label asp-for="PhoneNumber" class="col-form-label">@Loc["Address.Fields.PhoneNumber"]:</label>
<span class="required">*</span>
<input asp-for="PhoneNumber" v-model="createorupdatevendoraddress.PhoneNumber" v-bind:class="[classes , 'form-control']" data-val-required=@Loc["Account.VendorInfo.PhoneNumber.Required"]/>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="PhoneNumber"></span>
</validation-provider>
}
else
{
<label asp-for="PhoneNumber" class="col-form-label">@Loc["Address.Fields.PhoneNumber"]:</label>
<input asp-for="PhoneNumber" class="form-control"/>
}
<span asp-validation-for="PhoneNumber"></span>
</div>
}
@if (Model.FaxEnabled)
{
<div class="form-group col-sm-12 col-md-6">
@if (Model.FaxRequired)
{
<validation-provider tag="div" rules="required" :name="'@prefix' + '.FaxNumber'" v-slot="{ errors, classes }">
<label asp-for="FaxNumber" class="col-form-label">@Loc["Address.Fields.FaxNumber"]:</label>
<span class="required">*</span>
<input asp-for="FaxNumber" v-model="createorupdatevendoraddress.FaxNumber" v-bind:class="[classes , 'form-control']" data-val-required=@Loc["Account.VendorInfo.FaxNumber.Required"]/>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="FaxNumber"></span>
</validation-provider>
}
else
{
<label asp-for="FaxNumber" class="col-form-label">@Loc["Address.Fields.FaxNumber"]:</label>
<input asp-for="FaxNumber" class="form-control"/>
}
<span asp-validation-for="FaxNumber"></span>
</div>
}
</div>
@{
var addressVmData = new Dictionary<string, object> {
["Company"] = Model.Company,
["Address1"] = Model.Address1,
["Address2"] = Model.Address2,
["ZipPostalCode"] = Model.ZipPostalCode,
["City"] = Model.City,
//empty string, never null: these drive v-model on a <select>, and Vue
//matches the option by value - null matches nothing and clears the
//selection, where "" selects the "Select country" placeholder. The old
//inline script always produced a string because it interpolated into a
//JS literal.
["CountryId"] = Model.CountryId ?? "",
["StateProvinceId"] = Model.StateProvinceId ?? "",
["AvailableStates"] = Model.AvailableStates.Select(s => new { id = s.Value, name = s.Text }),
["PhoneNumber"] = Model.PhoneNumber,
["FaxNumber"] = Model.FaxNumber,
["prefix"] = prefix
};
}
@*Data island for the vendor address form; shares vueapp/src/views/country-state-form.js
with the customer address form.*@
<script type="application/json" data-grand-vm="countryStateForm">@Json.Serialize(new {
name = "createorupdatevendoraddress",
data = addressVmData,
routes = new { getStates = Url.RouteUrl("GetStatesByCountryId") },
elements = new {
countrySelectId = Html.IdFor(m => m.CountryId),
stateSelectId = Html.IdFor(m => m.StateProvinceId)
},
res = new { warning = Loc["common.warning"].ToString() }
})</script>