Вот код для просмотра
Код: Выделить всё
@L("Location")
@L("SelectALocation")
@if (Model.LocationId.HasValue)
{
@Model.LocationName
}
@L("MaterialUom")
Select an option
@if (Model.MaterialUomId > 0)
{
@Model.MaterialUomName
}
@L("Cost")
@{
int i = 0;
}
@foreach (var tier in @Model.LocationServicePrices)
{
@tier.PricingTierName
i++;
}
Код: Выделить всё
this.save = function() {
if (!_$form.valid()) {
_$form.showValidateMessage();
return;
}
var servicePrice = _$form.serializeFormToObject();
console.log(servicePrice);
_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);
});
};
[img]https://i.stack.imgur .com/C2vyU.png[/img]
Вот модель на BE
Код: Выделить всё
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; }
}
Код: Выделить всё
public async Task EditLocationService(LocationServiceEditDto input)
{
var locationServices = new List();
if (input.LocationServicePrices.Count > 0)
{
locationServices = input.LocationServicePrices.Select(x => new LocationServicePrice()
{
LocationServiceId = x.LocationServiceId,
PricingTierId = x.PricingTierId,
PricePerUnit = x.PricePerUnit
}).ToList();
}
await _locationServiceRepository.InsertOrUpdateAndGetIdAsync(new LocationService
{
Id = input.Id ?? 0,
ServiceId = input.ServiceId,
LocationId = input.LocationId,
Cost = input.Cost,
UnitOfMeasureId = input.MaterialUomId,
LocationServicePrices = locationServices
});
}
Код: Выделить всё
{
"Id": "",
"ServiceId": "2031",
"LocationId": "2",
"MaterialUomId": "6",
"Cost": "123",
"LocationServicePrices": {
"0.PricePerUnit": "1",
"1.PricePerUnit": "2",
"2.PricePerUnit": "3",
"3.PricePerUnit": "4",
"4.PricePerUnit": "5"
}
}
[img]https://i.stack .imgur.com/cQDaF.png[/img]
Как это исправить?
Подробнее здесь: https://stackoverflow.com/questions/782 ... lize-the-c