/// <summary> /// Initializes a new instance of the <see cref="IngredientEditViewModel"/> class. /// </summary> /// <param name="ingredientService">Ingredient service dependency.</param> /// <param name="dialogService">Dialog service dependency.</param> /// <param name="localization">Localization service dependency.</param> /// <param name="eventAggregator">Prism event aggregator.</param> /// <param name="ingredient">Ingredient to edit. Null means new ingredient.</param> public IngredientEditViewModel(CRUDService <Ingredient> ingredientService, DialogService dialogService, ILocalization localization, IEventAggregator eventAggregator, IngredientEdit?ingredient = null) : base(dialogService) { this.ingredientService = ingredientService; this.localization = localization; this.eventAggregator = eventAggregator; Ingredient = ingredient ?? new IngredientEdit(); AllIngredientNames = ingredientService.GetProperty(x => x.Name, filter: x => x.Name != null) .ConvertAll(x => x !); LoadedCommand = new DelegateCommand(OnLoaded); DeleteIngredientCommand = new DelegateCommand <Guid>(DeleteIngredientAsync); IngredientTypes = Enum.GetValues(typeof(IngredientType)).Cast <IngredientType>().ToList(); }