Вот модель
Код: Выделить всё
public class LocationServiceEditDto: EntityDto
{
public int ServiceId { get; set; }
public int? LocationId { get; set; }
public decimal? Cost { get; set; }
public int? MaterialUomId { get; set; }
public string MaterialUomName { get; set; }
public string LocationName => Location?.Name;
[JsonIgnore]
public LocationNameDto Location { get; set; }
public ICollection LocationServicePrices { get; set; }
}
А затем в View я показываю это вот так
Код: Выделить всё
@L("Location")
@L("SelectALocation")
@if (Model.LocationId.HasValue)
{
@Model.LocationName
}
@L("MaterialUom")
Select an option
@if (Model.MaterialUomId > 0)
{
@Model.MaterialUomName
}
@L("Cost")
@foreach (var tier in @Model.LocationServicePrices)
{
@tier.PricingTierName
}
На данный момент, когда я ввожу значения и отправить данные в BE, сбор равен нулю
Я сохраняю такие данные в файле .js
Код: Выделить всё
this.save = function () {
if (!_$form.valid()) {
_$form.showValidateMessage();
return;
}
var servicePrice = _$form.serializeFormToObject();
_modalManager.setBusy(true);
_serviceService.editLocationService(servicePrice).done(function () {
abp.notify.info('Saved successfully.');
_modalManager.close();
abp.event.trigger('app.createOrEditServicePriceModalSaved');
}).always(function () {
_modalManager.setBusy(false);
});
};
Код: Выделить всё
$.fn.serializeFormToObject = function () {
var $form = $(this);
var fields = $form.find('[disabled]');
fields.prop('disabled', false);
var json = $form.serializeJSON();
fields.prop('disabled', true);
return json;
};
Подробнее здесь: https://stackoverflow.com/questions/782 ... t-core-mvc