public override async Task <IDisplayResult> UpdateAsync(PricePart pricePart, IUpdateModel updater, UpdatePartEditorContext context) { var updateModel = new PricePartViewModel(); if (await updater.TryUpdateModelAsync(updateModel, Prefix, t => t.PriceValue, t => t.PriceCurrency)) { pricePart.Price = _moneyService.Create(updateModel.PriceValue, updateModel.PriceCurrency); } return(Edit(pricePart, context)); }
public override async Task <IDisplayResult> UpdateAsync(PricePart model, IUpdateModel updater) { var updateModel = new PricePartViewModel(); await updater.TryUpdateModelAsync(updateModel, Prefix, t => t.PriceValue); await updater.TryUpdateModelAsync(updateModel, Prefix, t => t.PriceCurrency); model.Price = _moneyService.Create(updateModel.PriceValue, updateModel.PriceCurrency); return(Edit(model)); }
private Task BuildViewModel(PricePartViewModel model, PricePart part) { model.ContentItem = part.ContentItem; model.Price = part.Price; model.PriceValue = part.Price.Value; model.PriceCurrency = part.Price.Currency == Currency.UnspecifiedCurrency ? _moneyService.DefaultCurrency.CurrencyIsoCode : part.Price.Currency.CurrencyIsoCode; model.PricePart = part; model.CurrentDisplayCurrency = _moneyService.CurrentDisplayCurrency; return(Task.CompletedTask); }
private Task BuildViewModel(PricePartViewModel model, PricePart part) { model.ContentItem = part.ContentItem; model.Price = part.Price; model.PriceValue = part.Price.Value; model.PriceCurrency = part.Price.Currency.IsoCode; model.PricePart = part; model.Currencies = _moneyService.Currencies; return(Task.CompletedTask); }