예제 #1
0
    private Task OnLoaded()
    {
        List <TagEdit> dbVals = tagService.GetProjected <TagEdit>();

        Tags = new ObservableCollection <TagEdit>(dbVals);

        return(Task.CompletedTask);
    }
예제 #2
0
    private Task OnLoaded()
    {
        List <IngredientEdit> dataDb = ingredientService.GetProjected <IngredientEdit>();

        Ingredients = new ObservableCollection <IngredientEdit>(dataDb);

        return(Task.CompletedTask);
    }
예제 #3
0
    /// <summary>
    /// Initializes a new instance of the <see cref="TagSelectViewModel"/> class.
    /// </summary>
    /// <param name="dialogService">Dialog service dependency.</param>
    /// <param name="tagService">Tag service dependency.</param>
    /// <param name="selectedTags">Alredy existing tags for editing.</param>
    /// <param name="allTags">All tags to select from.</param>
    public TagSelectViewModel(DialogService dialogService,
                              CRUDService <Tag> tagService,
                              IEnumerable <TagEdit> selectedTags,
                              IList <TagEdit>?allTags = null)
        : base(dialogService)
    {
        this.tagService = tagService;
        AddTagCommand   = new DelegateCommand(AddTagAsync);
        AllTags         = new ObservableCollection <TagEdit>(allTags ?? tagService.GetProjected <TagEdit>());
        SelectedItems.AddRange(AllTags.Intersect(selectedTags));

        AllTags.CollectionChanged += AllTags_CollectionChanged;
    }
    /// <summary>
    /// Initializes a new instance of the <see cref="RecipeIngredientEditViewModel"/> class.
    /// </summary>
    /// <param name="dialogService">Dialog service dependency.</param>
    /// <param name="ingredientService">Ingredient service dependency.</param>
    /// <param name="measureUnitService">Provider for a list of measurement units.</param>
    /// <param name="ingredient">Ingredient to edit.</param>
    public RecipeIngredientEditViewModel(DialogService dialogService,
                                         CRUDService <Ingredient> ingredientService,
                                         CRUDService <MeasureUnit> measureUnitService,
                                         RecipeIngredientEdit ingredient)
        : base(dialogService)
    {
        this.dialogService     = dialogService;
        this.ingredientService = ingredientService;

        Ingredient       = ingredient;
        MeasurementUnits = measureUnitService.GetAll();

        AddMultipleCommand      = new DelegateCommand(AddMultiple, canExecute: CanOk);
        RemoveIngredientCommand = new DelegateCommand <RecipeIngredientEdit>(RemoveIngredient);
        CreateIngredientCommand = new AsyncDelegateCommand(CreateIngredientAsync);

        AllIngredients = ingredientService.GetProjected <IngredientEdit>();
    }