private async Task SaveVoertuigStateAsync()
        {
            currentVoertuigen = new Voertuigen();
            currentVoertuigen = voertuigenService.GetVoertuigenLijst(3).Result;

            currentKlant                = new Klant();
            currentKlant.Naam           = Naam;
            currentKlant.Telefoonnummer = Telefoonnummer;
            //currentKlant.Email = Email;
            currentKlant.Adres       = Adres;
            currentKlant.KlantStatus = KlantStatus.Koper;
            currentKlant.Woonplaats  = Woonplaats;
            currentKlant.Id          = new Guid();

            await klantenService.SaveKlant(currentKlant);

            await klantenService.GetKlantById(currentKlant.Id);


            //currentAuto = new Auto();
            currentAuto.Merk      = Merk;
            currentAuto.Model     = Model;
            currentAuto.Prijs     = Convert.ToDecimal(Prijs);
            currentAuto.Bouwjaar  = Convert.ToInt16(Bouwjaar);
            currentAuto.Vraag     = Convert.ToDateTime(currentAuto.Vraag.ToString("dd-MMM-yyyy"));
            currentAuto.KlantNaam = currentKlant.Naam;
            currentAuto.KlantId   = currentKlant.Id;

            //currentVoertuigen.Autoos.Add(currentAuto);

            await voertuigenService.SaveVoertuigenLijst(currentVoertuigen);


            if (currentAuto.AutoStatus == (AutoStatus)Enum.Parse(typeof(AutoStatus), "Gekocht"))
            {
                var autolijst = await voertuigenService.GetVoertuigenLijst(1);

                if (autolijst.Autoos == null)
                {
                    autolijst.Autoos = new List <Auto>();
                }
                autolijst.Autoos.Add(currentAuto);
                currentVoertuigen.Autoos.Remove(currentAuto);
                await voertuigenService.SaveVoertuigenLijst(autolijst);

                await voertuigenService.SaveVoertuigenLijst(currentVoertuigen);
            }
            await voertuigenService.SaveVoertuigenLijst(currentVoertuigen);
        }
Ejemplo n.º 2
0
        private async Task SaveVoertuigStateAsync()
        {
            currentVoertuigen = new Voertuigen();
            currentVoertuigen = voertuigenService.GetVoertuigenLijst(0).Result;

            currentKlant                = new Klant();
            currentKlant.Naam           = Naam;
            currentKlant.Telefoonnummer = Telefoonnummer;
            currentKlant.Email          = Email;
            currentKlant.Adres          = Adres;
            currentKlant.KlantStatus    = KlantStatus.Verkoper;
            currentKlant.Woonplaats     = Woonplaats;
            currentKlant.Id             = new Guid();

            await klantenService.SaveKlant(currentKlant);

            await klantenService.GetKlantById(currentKlant.Id);

            currentKlant.Auto = new Auto();



            currentAuto           = new Auto();
            currentAuto.Merk      = Merk;
            currentAuto.Model     = Model;
            currentAuto.Prijs     = Convert.ToDecimal(Prijs);
            currentAuto.Bouwjaar  = Convert.ToInt16(Bouwjaar);
            currentAuto.AanBod    = Aanbod;
            currentAuto.KlantNaam = currentKlant.Naam;
            currentAuto.KlantId   = currentKlant.Id;

            currentVoertuigen.Autoos.Add(currentAuto);

            await voertuigenService.SaveVoertuigenLijst(currentVoertuigen);

            currentKlant.Auto.AanBod = currentAuto.AanBod;
            currentKlant.Auto.Merk   = currentAuto.Merk;
            currentKlant.Auto.Model  = currentAuto.Model;
            currentKlant.Auto.Prijs  = currentAuto.Prijs;
            currentKlant.AutoId      = currentAuto.Id;
        }