Ejemplo n.º 1
0
        static void AddToDatabase(Stream stream)
        {
            DefaultDeserializer deserializer = new DefaultDeserializer(stream);

            deserializer.Deserialize();

            CarsDBContext db = new CarsDBContext();

            //gets reference to added report for later
            Reports addedReport;

            try
            {
                addedReport = AddReport(db, deserializer.Document.ToString());
                db.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }

            try
            {
                AddCarProducts(db, deserializer);
                db.SaveChanges();

                AddCarProductCarFeature(db, deserializer);
                db.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }

            ConfirmReport(context: db, reportToConfirm: addedReport);
            db.SaveChanges();
        }