private void FilterMachineInformationSelected(MachineInformation machineInformation)
        {
            if (machineInformation == null)
            {
                return;
            }

            var location = cbLocations.SelectedItem as Location;

            if (location == null || location.Id != machineInformation.LocationId)
            {
                SetFilterSelectedCbItem(cbLocations,
                                        () => { return(ManagementVM.Locations.Where(c => c.Id == machineInformation.LocationId)); });
            }
        }
        private void SetMachineInformationData(MachineInformation machineInformation)
        {
            lblMachineInfoName.Content               = machineInformation.GetDisplayName <MachineInformation>(nameof(machineInformation.Name)) + ":";
            lblMachineInfoSerialNumber.Content       = machineInformation.GetDisplayName <MachineInformation>(nameof(machineInformation.SerialNumber)) + ":";
            lblMachineInfoHoldingPositions.Content   = machineInformation.GetDisplayName <MachineInformation>(nameof(machineInformation.HoldingPositions)) + ":";
            lblMachineInfoEntrances.Content          = machineInformation.GetDisplayName <MachineInformation>(nameof(machineInformation.Entrances)) + ":";
            lblMachineInfoYearOfConstruction.Content = machineInformation.GetDisplayName <MachineInformation>(nameof(machineInformation.YearOfConstruction)) + ":";
            lblMachineInfoPayload.Content            = machineInformation.GetDisplayName <MachineInformation>(nameof(machineInformation.Payload)) + ":";

            lblMachineInfoNameValue.Content               = machineInformation.Name;
            lblMachineInfoSerialNumberValue.Content       = machineInformation.SerialNumber;
            lblMachineInfoHoldingPositionsValue.Content   = machineInformation.HoldingPositions;
            lblMachineInfoEntrancesValue.Content          = machineInformation.Entrances;
            lblMachineInfoYearOfConstructionValue.Content = machineInformation.YearOfConstruction.ToString("dd.MM.yyyy");
            lblMachineInfoPayloadValue.Content            = machineInformation.Payload;
        }
        private void SetFilterMachineInformation(MachineInformation machineInformation)
        {
            if (machineInformation == null)
            {
                spRecordBtns.IsEnabled = false;
                dgOthers.IsEnabled     = false;
                return;
            }

            recordView.RecordVM.MachineInformationSelected = machineInformation;

            Task.Factory.StartNew(() => ManagementVM.AddOtherInformations(ManagementVM.MachineInformationSelected))
            .ContinueWith(task => ManagementVM.MachineInformationSelected = machineInformation);

            spRecordBtns.IsEnabled = true;
            dgOthers.IsEnabled     = true;

            // Task.Factory.StartNew (()=>recordsView.RecordsVM.Refresh(machineInformation));
            recordsView.RecordsVM.Refresh(machineInformation);
            FilterMachineInformationSelected(machineInformation);

            var location             = cbLocations.SelectedItem as Location;
            var customer             = cbCustomers.SelectedItem as Customer;
            var machineInfo          = cbMachineInformations.SelectedItem as MachineInformation;
            var maintenanceAgreement = ManagementVM.MaintenanceAgreements
                                       .Where(c => c.MachineInformationId == machineInfo.Id).FirstOrDefault();

            //Task.Factory.StartNew(() => ManagementVM.RefreshOtherInformations(machineInformation));

            ManagementVM.RefreshOtherInformations(machineInformation);

            SetLocationData(location);
            SetCustomerData(customer);
            SetMaintenanceAgreementData(maintenanceAgreement);
            SetEmergencyAgreementData(maintenanceAgreement);
            SetMachineInformationData(machineInfo);

            List <ContactPartner> contactPersons = new List <ContactPartner>();

            contactPersons.AddRange(customer.Administrator.ContactPersons);
            contactPersons.Add(customer.ContactPerson);
            contactPersons.Add(location.ContactPerson);
            contactPersons.Add(machineInfo.ContactPerson);

            dgContactPersons.ItemsSource = contactPersons.OrderByDescending(c => c.ContactByDefect).ToList();
            // dgContactPersons.Tag = new List<string> { nameof(ContactPartner.EMail) };
        }