public async Task SavePreferenceAsync(PreferenceDto preference) { var previousPreference = await _preferenceRepository.GetPreferenceAsync(preference.EmployeeId, preference.DrinkId); await _preferenceRepository.SavePreferenceAsync( Preference.Create( preference.EmployeeId, preference.DrinkId, new DrinkPreference( preference.Amounts.Select(a => new IngredientAmount(a.DrinkIngredientId, a.Amount)), preference.Mug ), preferenceId: previousPreference?.PreferenceId ?? 0)); }