using SewerStammGen.Shared.Contracts;
using SewerStammGen.Shared.Domain;
using StammGenerator.Commands;
using StammGenerator.Interface;
using StammGenerator.ViewModel;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace StammGenerator.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();
            
        }
    }
}
