/// <summary>
        /// Ruft die Informationen aus dem Formular ab und speichert sie in die Datenbank.
        /// Wirft eine Fehlermeldung, wenn die Validierung fehlschlägt.
        /// </summary>
        private void ProducerSave_Click(object sender, RoutedEventArgs e)
        {
            ProducerDataAccess dataAccess = new ProducerDataAccess();
            ProducerValidator validator = new ProducerValidator();

            try
            {
                this.setEntityWithFormData();

                if (!validator.CheckConsistency(this.entity))
                {
                    ErrorHandler.ShowErrorMessage("Validierung fehlgeschlagen", ErrorHandler.VALIDATION_FAILED);
                }
                else
                {
                    if (this.isAvailable)
                        dataAccess.Update(this.entity);
                    else
                        dataAccess.Save(this.entity);
                    this.Close();
                }
            }
            catch (FormatException exception)
            {
                ErrorHandler.ShowErrorMessage(exception, ErrorHandler.WRONG_FORMAT);
            }
            catch (MySql.Data.MySqlClient.MySqlException exception)
            {
                ErrorHandler.ShowErrorMessage(exception, ErrorHandler.SAVE_WENT_WRONG);
            }
            catch (System.OverflowException exception)
            {
                ErrorHandler.ShowErrorMessage(exception, ErrorHandler.DATA_TOO_LONG);
            }
        }
        public void deleteProducerFromDatabase()
        {
            ProducerDataAccess dataAccess = new ProducerDataAccess();
            Producer producer = dataAccess.GetLastEntity<Producer>();

            dataAccess.Delete(producer.Id);

            Assert.IsTrue(dataAccess.GetLastEntity<Producer>() == null || producer.Id == dataAccess.GetLastEntity<Producer>().Id);
        }
        /// <summary>
        /// Fügt alle Hersteller aus der Datenbank dem Drop-Down-Menü hinzu
        /// </summary>
        private void GetProducers()
        {
            ProducerDataAccess dataProducers = new ProducerDataAccess();
            List<Producer> producers = dataProducers.GetAllEntities<Producer>();

            foreach (Producer element in producers)
            {
                this.RamProducer.Items.Add(element.CompanyName.ToString());
            }
        }
        /// <summary>
        /// Mappt einen Datensatz aus der Datenbank auf ein Objekt vom Typ 'Arbeitsspeicher'
        /// </summary>
        /// <param name="reader">Der Datensatz, welcher gemappt wird</param>
        /// <returns>RandomAccessMemory</returns>
        protected override object MapToEntity(MySqlDataReader reader)
        {
            RandomAccessMemory ram = new RandomAccessMemory();
            ProducerDataAccess producerDataAccess = new ProducerDataAccess();

            ram.Id = Int32.Parse(reader.GetValue(0).ToString());
            ram.Description = reader.GetValue(1).ToString();
            ram.Memory = ulong.Parse(reader.GetValue(2).ToString());
            ram.ClockRate = Double.Parse(reader.GetValue(3).ToString());
            ram.Producer = producerDataAccess.GetEntityById<Producer>(Int32.Parse(reader.GetValue(4).ToString()));

            return ram;
        }
        /// <summary>
        /// Mappt einen Datensatz aus der Datenbank auf ein Objekt vom Typ 'Prozessor'
        /// </summary>
        /// <param name="reader">Der Datensatz, welcher gemappt wird</param>
        /// <returns>Processor</returns>
        protected override object MapToEntity(MySqlDataReader reader)
        {
            Processor processor = new Processor();
            ProducerDataAccess producerDataAccess = new ProducerDataAccess();

            processor.Id = Int32.Parse(reader.GetValue(0).ToString());
            processor.Description = reader.GetValue(1).ToString();
            processor.Model = reader.GetValue(2).ToString();
            processor.Core = uint.Parse(reader.GetValue(3).ToString());
            processor.CommandSet = reader.GetValue(4).ToString();
            processor.Architecture = uint.Parse(reader.GetValue(5).ToString());
            processor.ClockRate = Double.Parse(reader.GetValue(6).ToString());
            processor.Producer = producerDataAccess.GetEntityById<Producer>(Int32.Parse(reader.GetValue(7).ToString()));

            return processor;
        }
        public void getDiskFromDatabase()
        {
            DiskDataAccess dataAccess = new DiskDataAccess();
            ProducerDataAccess producerDataAccess = new ProducerDataAccess();
            PhysicalInterfaceDataAccess physicalInterfaceDataAccess = new PhysicalInterfaceDataAccess();
            Disk hdd = new Disk();

            hdd.Description = "Dies ist ein Test";
            hdd.Capacity = 1000;
            hdd.Ssd = false;
            hdd.Inch = 3.5;
            hdd.Producer = producerDataAccess.GetLastEntity<Producer>();
            hdd.AddPhysicalInterface(new PhysicalInterfaceWithCount(physicalInterfaceDataAccess.GetLastEntity<PhysicalInterface>(), 3));

            dataAccess.Save(hdd);
            Disk dbHDD = dataAccess.GetLastEntity<Disk>();

            Assert.AreEqual(hdd.Capacity, dbHDD.Capacity);
        }
        /// <summary>
        /// Mappt einen Datensatz aus der Datenbank auf ein Objekt vom Typ 'Hauptplatine'
        /// </summary>
        /// <param name="reader">Der Datensatz, welcher gemappt wird</param>
        /// <returns>Motherboard</returns>
        protected override object MapToEntity(MySqlDataReader reader)
        {
            Motherboard motherboard = new Motherboard();
            ProducerDataAccess producerDataAccess = new ProducerDataAccess();

            motherboard.Id = Int32.Parse(reader.GetValue(0).ToString());
            motherboard.Description = reader.GetValue(1).ToString();
            motherboard.Inch = Double.Parse(reader.GetValue(2).ToString());
            motherboard.Socket = reader.GetValue(3).ToString();
            motherboard.Producer = producerDataAccess.GetEntityById<Producer>(Int32.Parse(reader.GetValue(4).ToString()));
            motherboard.PhysicalInterfaces = this.GetPhysicalInterfaces(motherboard);

            return motherboard;
        }
        public void getProducerFromDatabase()
        {
            ProducerDataAccess dataAccess = new ProducerDataAccess();
            Producer producer = new Producer();

            producer.CompanyName = "Siemens";
            producer.PhoneNumber = "123456";
            producer.Email = "*****@*****.**";
            producer.Website = "www.siemens.de";
            producer.PostalCode = 21335;
            producer.Place = "Lüneburg";
            producer.Street = "Lüneburger Straße";
            producer.HouseNumber = 1;

            dataAccess.Save(producer);
            Producer dbProducer = dataAccess.GetLastEntity<Producer>();

            Assert.AreEqual(producer.Website, dbProducer.Website);
        }
        public void getMotherboardFromDatabase()
        {
            MotherboardDataAccess dataAccess = new MotherboardDataAccess();
            ProducerDataAccess producerDataAccess = new ProducerDataAccess();
            PhysicalInterfaceDataAccess physicalInterfaceDataAccess = new PhysicalInterfaceDataAccess();
            Motherboard motherboard = new Motherboard();

            motherboard.Description = "Dies ist ein Test";
            motherboard.Inch = 24.2;
            motherboard.Socket = "PGA 988B";
            motherboard.Producer = producerDataAccess.GetLastEntity<Producer>();
            motherboard.AddPhysicalInterface(new PhysicalInterfaceWithCount(physicalInterfaceDataAccess.GetLastEntity<PhysicalInterface>(), 3));

            dataAccess.Save(motherboard);
            Motherboard dbMotherboard = dataAccess.GetLastEntity<Motherboard>();

            Assert.AreEqual(motherboard.Socket, dbMotherboard.Socket);
        }
 /// <summary>
 /// Setzt die Werte des Formulares in der entity.
 /// </summary>
 /// <param name="dataProducer">Dataaccess Objekt eines Produzenten</param>
 private void setEntityWithFormData(ProducerDataAccess dataProducer)
 {
     this.entity.Description = this.description.Text;
     this.entity.Inch = Convert.ToDouble(this.size.Text.Replace('.', ','));
     this.entity.Producer = dataProducer.GetEntityByName<Producer>("Firma", this.producer.Text.ToString());
     this.entity.Socket = this.socket.Text;
 }
 /// <summary>
 /// Setzt die Werte des Formulares in der entity.
 /// </summary>
 /// <param name="dataProducer">Dataaccess Objekt eines Produzenten</param>
 private void setEntityWithFormData(ProducerDataAccess dataProducer = null)
 {
     this.entity.Name = this.interfaceName.Text;
     this.entity.Description = this.interfaceDescription.Text;
     this.entity.Serial = Convert.ToBoolean(this.interfaceSerial.IsChecked);
     this.entity.TransferRate = Convert.ToDouble(this.interfaceTransferRate.Text.Replace('.', ','));
 }
        /// <summary>
        /// Mappt einen Datensatz aus der Datenbank auf ein Objekt vom Typ 'Grafikkarte'
        /// </summary>
        /// <param name="reader">Der Datensatz, welcher gemappt wird</param>
        /// <returns>GraphicCard</returns>
        protected override object MapToEntity(MySqlDataReader reader)
        {
            GraphicCard graphicCard = new GraphicCard();
            ProducerDataAccess producerDataAccess = new ProducerDataAccess();

            graphicCard.Id = Int32.Parse(reader.GetValue(0).ToString());
            graphicCard.Description = reader.GetValue(1).ToString();
            graphicCard.ClockRate = Double.Parse(reader.GetValue(2).ToString());
            graphicCard.Model = reader.GetValue(3).ToString();
            graphicCard.Memory = ulong.Parse(reader.GetValue(4).ToString());
            graphicCard.Producer = producerDataAccess.GetEntityById<Producer>(Int32.Parse(reader.GetValue(5).ToString()));
            graphicCard.PhysicalInterfaces = this.GetPhysicalInterfaces(graphicCard);

            return graphicCard;
        }
 /// <summary>
 /// Setzt die Werte des Formulares in der entity.
 /// </summary>
 /// <param name="dataProducer">Dataaccess Objekt eines Produzenten</param>
 private void setEntityWithFormData(ProducerDataAccess dataProducer)
 {
     this.entity.Description = this.description.Text;
     this.entity.Resolution = this.resolution.Text;
     this.entity.Inch = double.Parse(this.inch.Text.Replace('.',','));
     this.entity.AspectRatio = this.aspectRatio.Text;
     this.entity.Producer = dataProducer.GetEntityByName<Producer>("Firma", this.producer.Text.ToString());
 }
 /// <summary>
 /// Setzt die Werte des Formulares in der entity.
 /// </summary>
 /// <param name="dataProducer">Dataaccess Objekt eines Produzenten</param>
 private void setEntityWithFormData(ProducerDataAccess dataProducer)
 {
     this.entity.Description = this.description.Text;
     this.entity.Model = this.model.Text;
     this.entity.Producer = dataProducer.GetEntityByName<Producer>("Firma", this.producer.Text.ToString());
     this.entity.CommandSet = this.commandSet.Text;
     this.entity.Architecture = uint.Parse(this.architecture.Text);
     this.entity.ClockRate = double.Parse(this.clockRate.Text.Replace(".", ","));
     this.entity.Core = uint.Parse(this.cores.Text);
 }
        public void getGraphicCardFromDatabase()
        {
            GraphicCardDataAccess dataAccess = new GraphicCardDataAccess();
            ProducerDataAccess producerDataAccess = new ProducerDataAccess();
            PhysicalInterfaceDataAccess physicalInterfaceDataAccess = new PhysicalInterfaceDataAccess();
            GraphicCard graphicCard = new GraphicCard();

            graphicCard.Description = "Dies ist ein Test";
            graphicCard.ClockRate = 5;
            graphicCard.Model = "GTX1234";
            graphicCard.Memory = 2000;
            graphicCard.Producer = producerDataAccess.GetLastEntity<Producer>();
            graphicCard.AddPhysicalInterface(new PhysicalInterfaceWithCount(physicalInterfaceDataAccess.GetLastEntity<PhysicalInterface>(), 3));

            dataAccess.Save(graphicCard);
            GraphicCard dbGraphicCard = dataAccess.GetLastEntity<GraphicCard>();

            Assert.AreEqual(graphicCard.Description, dbGraphicCard.Description);
        }
        public void getMonitorFromDatabase()
        {
            MonitorDataAccess dataAccess = new MonitorDataAccess();
            ProducerDataAccess producerDataAccess = new ProducerDataAccess();
            PhysicalInterfaceDataAccess physicalInterfaceDataAccess = new PhysicalInterfaceDataAccess();
            Monitor monitor = new Monitor();

            monitor.Description = "Dies ist ein Test";
            monitor.Resolution = "1280*800";
            monitor.Inch = 24;
            monitor.AspectRatio = "16:9";
            monitor.Producer = producerDataAccess.GetLastEntity<Producer>();
            monitor.AddPhysicalInterface(new PhysicalInterfaceWithCount(physicalInterfaceDataAccess.GetLastEntity<PhysicalInterface>(), 3));

            dataAccess.Save(monitor);
            Monitor dbMonitor = dataAccess.GetLastEntity<Monitor>();

            Assert.AreEqual(monitor.Inch, dbMonitor.Inch);
        }
        /// <summary>
        /// Setzt die Werte des Formulares in der entity.
        /// </summary>
        /// <param name="dataProducer">Dataaccess Objekt eines Produzenten</param>
        private void setEntityWithFormData(ProducerDataAccess dataProducer)
        {
            this.entity.Description = this.DiskDescription.Text;
            if (this.DiskCapacityUnit.Text == "MB")
            {
                this.entity.Capacity = Convert.ToUInt32(this.DiskCapacity.Text);
            }
            else if (this.DiskCapacityUnit.Text == "GB")
            {
                this.entity.Capacity = UnitConverter.ConvertToLower(Convert.ToUInt32(this.DiskCapacity.Text));
            }

            this.entity.Inch = Convert.ToDouble(this.DiskSize.Text.Replace('.', ','));
            this.entity.Ssd = Convert.ToBoolean(this.DiskType.IsChecked);
            this.entity.Producer = dataProducer.GetEntityByName<Producer>("Firma", this.DiskProducer.Text.ToString());
        }
        public void getProcessorFromDatabase()
        {
            ProcessorDataAccess dataAccess = new ProcessorDataAccess();
            ProducerDataAccess producerDataAccess = new ProducerDataAccess();
            Processor processor = new Processor();

            processor.Description = "Dies ist ein Test";
            processor.Model = "i5";
            processor.Core = 4;
            processor.CommandSet = "RISC";
            processor.Architecture = 64;
            processor.ClockRate = 3.40;
            processor.Producer = producerDataAccess.GetLastEntity<Producer>();

            dataAccess.Save(processor);
            Processor dbProcessor = dataAccess.GetLastEntity<Processor>();

            Assert.AreEqual(processor.CommandSet, dbProcessor.CommandSet);
        }
        /// <summary>
        /// Mappt einen Datensatz aus der Datenbank auf ein Objekt vom Typ 'Monitor'
        /// </summary>
        /// <param name="reader">Der Datensatz, welcher gemappt wird</param>
        /// <returns>Monitor</returns>
        protected override object MapToEntity(MySqlDataReader reader)
        {
            Monitor monitor = new Monitor();
            ProducerDataAccess producerDataAccess = new ProducerDataAccess();
            PhysicalInterfaceDataAccess physicalInterfaceDataAccess = new PhysicalInterfaceDataAccess();

            monitor.Id = Int32.Parse(reader.GetValue(0).ToString());
            monitor.Description = reader.GetValue(1).ToString();
            monitor.Resolution = reader.GetValue(2).ToString();
            monitor.Inch = Double.Parse(reader.GetValue(3).ToString());
            monitor.AspectRatio = reader.GetValue(4).ToString();
            monitor.Producer = producerDataAccess.GetEntityById<Producer>(Int32.Parse(reader.GetValue(5).ToString()));
            monitor.PhysicalInterfaces = this.GetPhysicalInterfaces(monitor);

            return monitor;
        }
        public void getRandomAccessMemoryFromDatabase()
        {
            RandomAccessMemoryDataAccess dataAccess = new RandomAccessMemoryDataAccess();
            ProducerDataAccess producerDataAccess = new ProducerDataAccess();
            RandomAccessMemory ram = new RandomAccessMemory();

            ram.Description = "Dies ist ein Test";
            ram.Memory = 8000;
            ram.ClockRate = 12000;
            ram.Producer = producerDataAccess.GetLastEntity<Producer>();

            dataAccess.Save(ram);
            RandomAccessMemory dbRAM = dataAccess.GetLastEntity<RandomAccessMemory>();

            Assert.AreEqual(ram.Memory, dbRAM.Memory);
        }
        /// <summary>
        /// Setzt die Werte des Formulares in der entity.
        /// </summary>
        /// <param name="dataProducer">Dataaccess Objekt eines Produzenten</param>
        private void setEntityWithFormData(ProducerDataAccess dataProducer)
        {
            this.entity.Description = this.RamDescription.Text.ToString();
            this.entity.ClockRate = double.Parse(this.RamClockRate.Text.Replace('.', ','));
            this.entity.Producer = dataProducer.GetEntityByName<Producer>("Firma", this.RamProducer.Text.ToString());

            if (this.RamStorageUnit.Text == "MB")
            {
                this.entity.Memory = ulong.Parse(this.RamStorage.Text);
            }
            else if (this.RamStorageUnit.Text == "GB")
            {
                this.entity.Memory = UnitConverter.ConvertToLower(Convert.ToDouble(this.RamStorage.Text));
            }
        }
        /// <summary>
        /// Mappt einen Datensatz aus der Datenbank auf ein Objekt vom Typ 'Festplatte'
        /// </summary>
        /// <param name="reader">Der Datensatz, welcher gemappt wird</param>
        /// <returns>Disk</returns>
        protected override object MapToEntity(MySqlDataReader reader)
        {
            Disk disk = new Disk();
            ProducerDataAccess producerDataAccess = new ProducerDataAccess();

            disk.Id = Int32.Parse(reader.GetValue(0).ToString());
            disk.Description = reader.GetValue(1).ToString();
            disk.Capacity = ulong.Parse(reader.GetValue(2).ToString());
            disk.Ssd = Boolean.Parse(reader.GetValue(3).ToString());
            disk.Inch = Double.Parse(reader.GetValue(4).ToString());
            disk.Producer = producerDataAccess.GetEntityById<Producer>(Int32.Parse(reader.GetValue(5).ToString()));
            disk.PhysicalInterfaces = this.GetPhysicalInterfaces(disk);

            return disk;
        }
 /// <summary>
 /// Setzt die Werte des Formulares in der entity.
 /// </summary>
 /// <param name="dataProducer">Dataaccess Objekt eines Produzenten</param>
 private void setEntityWithFormData(ProducerDataAccess dataProducer = null)
 {
     this.entity.CompanyName = this.ProducerCompanyName.Text;
     this.entity.Email = this.ProducerEmail.Text;
     this.entity.PhoneNumber = this.ProducerTelephone.Text;
     this.entity.Website = this.ProducerWebsite.Text;
     this.entity.PostalCode = uint.Parse(this.ProducerPostalCode.Text);
     this.entity.Place = this.ProducerPlace.Text;
     this.entity.Street = this.ProducerStreet.Text;
     this.entity.HouseNumber = uint.Parse(this.ProducerHouseNumber.Text);
 }