private async void OpenEditUnitDialogAsync(FoodUnit unit) { var unitClone = unit.Clone(); var dialog = _dialogs.For <FoodUnitDialogViewModel>(FoodDialogDialogsIdentifier); dialog.Data.FoodUnit = FoodUnitViewModel.FromModel(unitClone); dialog.Data.DialogTitle = "Modified food unit"; dialog.Data.SubmitButtonTitle = "Save"; var dialogResult = await dialog.Show(); if (dialogResult != DialogResult.Ok) { return; } unitClone = dialog.Data.FoodUnit.ToModel(); Food.Units.Replace(unit, unitClone); }
private async void OpenAddUnitDialogAsync() { var unit = new FoodUnit { Grams = FoodUnitConstants.MinimumAllowedUnitGrams }; var dialog = _dialogs.For <FoodUnitDialogViewModel>(FoodDialogDialogsIdentifier); dialog.Data.FoodUnit = FoodUnitViewModel.FromModel(unit); dialog.Data.DialogTitle = "New food unit"; dialog.Data.SubmitButtonTitle = "Create"; var dialogResult = await dialog.Show(); if (dialogResult != DialogResult.Ok) { return; } unit = dialog.Data.FoodUnit.ToModel(); Food.Units.Add(unit); }