Esempio n. 1
0
        public static Ownerinfo GetSelectedCarsoOwnerinfo(int carId)
        {
            Ownerinfo            infOwnerinfo = new Ownerinfo();
            CarsSellingEntities1 context      = new CarsSellingEntities1();

            foreach (TbOwnersInfo info in context.TbOwnersInfoes)
            {
                if (info.TbCarsInfo.Id == carId)
                {
                    infOwnerinfo.Vorname  = info.Vorname;
                    infOwnerinfo.Nachname = info.nachname;
                    string value = Encoding.ASCII.GetString(info.TelephoneNumber);
                    infOwnerinfo.Telephonenumber = value;
                    infOwnerinfo.Emailadress     = info.EmailAdress;
                }
            }
            return(infOwnerinfo);
        }
Esempio n. 2
0
        public static void AddNewOffer(CarsInfo car, List <CarsFoto> fotos, Ownerinfo owner)
        {
            CarsSellingEntities1 context = new CarsSellingEntities1();
            TbCarsInfo           newcar  = new TbCarsInfo();

            newcar.Modell    = car.Modell;
            newcar.Status    = car.Status;
            newcar.Insurance = car.Insurance;
            newcar.Adress    = car.Adress;
            newcar.Price     = car.Price;
            newcar.Sold      = car.Sold;
            context.TbCarsInfoes.Add(newcar);
            context.SaveChanges();
            int id = newcar.Id;

            foreach (CarsFoto carsFoto in fotos)
            {
                TbCarsFoto newCarsFoto = new TbCarsFoto();
                newCarsFoto.CarId = id;
                newCarsFoto.Foto  = carsFoto.Foto;
                context.TbCarsFotoes.Add(newCarsFoto);
                context.SaveChanges();
            }
            TbOwnersInfo newowner = new TbOwnersInfo();

            newowner.Vorname  = owner.Vorname;
            newowner.nachname = owner.Nachname;
            byte[] telephonenumber = Encoding.ASCII.GetBytes(owner.Telephonenumber);

            newowner.TelephoneNumber = telephonenumber;
            newowner.EmailAdress     = owner.Emailadress;
            newowner.CarId           = id;

            context.TbOwnersInfoes.Add(newowner);
            context.SaveChanges();
        }