using SewerStammGen.Shared.Contracts;
using SewerStammGen.Shared.Domain;
using SewerStammGen.WPF.Interface.Navigator;
using SewerStammGen.WPF.ViewModel.State;
using Shared.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SewerStammGen.WPF.Commands
{
    internal class ProjektAddCommand : AsyncCommandBase
    {
        private readonly IActualState _actualState;
        private readonly IProjektDataService _generic;
        private readonly IRenavigator _renavigator;

        public ProjektAddCommand(IProjektDataService generic, IActualState actualState, IRenavigator renavigator)
        {
            _renavigator = renavigator;
            _generic = generic;
            _actualState = actualState;
        }

        public override async Task ExecuteAsync(object? parameter)
        {
            Projekt newProjekt = new Projekt()
            {
                Erstelldatum = "",
                Strasse = "",
                Ort = "",
                Projektname = "",
                Auftraggeber = new Auftraggeber(),
                Schaechte = new List<Schacht>(),
                Kanaele = new List<Kanal>()
            };
            newProjekt = await _generic.Create(newProjekt);
            _actualState.SetProjekt(newProjekt);
            _renavigator.Renavigate();
            
        }
    }
}
