Ejemplo n.º 1
0
        private void BuildingComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (BuildingComboBox.SelectedItem != null)
            {
                buildingType = BuildingSetType.Text = BuildingService.GetBuilding()
                                                      .Where(x => (x.Type == BuildingComboBox.SelectedItem.ToString()))
                                                      .Select(x => x.Type).FirstOrDefault().ToString();

                buildingWindows = BuildingSetWindows.Text = BuildingService.GetBuilding()
                                                            .Where(x => (x.Type == BuildingComboBox.SelectedItem.ToString()))
                                                            .Select(x => x.InfoWindows).FirstOrDefault().ToString();

                buildingIndustrial = BuildingSetIsIndustrial.Text = BuildingService.GetBuilding()
                                                                    .Where(x => (x.Type == BuildingComboBox.SelectedItem.ToString()))
                                                                    .Select(x => x.InfoIndustrial).FirstOrDefault().ToString();
            }
        }
Ejemplo n.º 2
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            string _countryName      = CountrySetName.Text;
            string _countryContinent = CountrySetContinent.Text;
            string _presidentName    = PresidentSetName.Text;
            int    _presidentAge;
            bool   _presidentAgeBool = Int32.TryParse(PresidentSetAge.Text, out _presidentAge);
            string _cityName         = CitySetName.Text;
            int    _cityPopulation;
            bool   _cityPopulationBool = Int32.TryParse(CitySetPopulation.Text, out _cityPopulation);
            string _placeStreet        = PlaceSetStreet.Text;
            int    _placePopulation;
            bool   _placePopulationBool = Int32.TryParse(PlaceSetPopulation.Text, out _placePopulation);
            string _buildingType        = BuildingSetType.Text;
            string _buildingWindows     = BuildingSetWindows.Text;
            string _buildingIndustrial  = BuildingSetIsIndustrial.Text;
            bool   _buildingWindowsBool;
            bool   _buildingIndustrialBool;

            if (_buildingWindows.ToUpper().Trim() == "TAK")
            {
                _buildingWindowsBool = true;
            }
            else
            {
                _buildingWindowsBool = false;
            }
            if (_buildingIndustrial.ToUpper().Trim() == "TAK")
            {
                _buildingIndustrialBool = true;
            }
            else
            {
                _buildingIndustrialBool = false;
            }

            if (_countryName == "" || _presidentName == "")
            {
                MessageBox.Show("Nie została podana nazwa państwa lub/i nazwisko prezydenta");
                return;
            }
            if (!_presidentAgeBool || !_cityPopulationBool || !_placePopulationBool)
            {
                MessageBox.Show("Wartości dla wieku czy populacji należy podawać w liczbach całkowitych");
                return;
            }

            if (_countryName == countryName)
            {
                if (_countryContinent != countryContinent)
                {
                    CountryService.SaveCountry(_countryName, _countryContinent, Id_Country);
                }


                if (_cityName == cityName && _cityPopulation != Convert.ToInt32(cityPopulation))
                {
                    CityService.SaveCity(_cityName, Convert.ToInt32(_cityPopulation), Id_Country, Id_City);
                }

                if (_cityName != cityName)
                {
                    CityService.SaveCity(_cityName, Convert.ToInt32(_cityPopulation), Id_Country);
                    Id_City = CityService.GetCity().Select(x => x.Id).LastOrDefault();
                }

                if ((_buildingType == buildingType && (_buildingWindows != buildingWindows || _buildingIndustrial != buildingIndustrial)))
                {
                    BuildingService.SaveBuilding(_buildingType, _buildingWindowsBool, _buildingIndustrialBool, Place_Id_Building);
                }

                if (_buildingType != buildingType)
                {
                    BuildingService.SaveBuilding(_buildingType, _buildingWindowsBool, _buildingIndustrialBool);
                    Place_Id_Building = BuildingService.GetBuilding().Select(x => x.Id).LastOrDefault();
                }

                if (_placeStreet == placeStreet && _placePopulation != Convert.ToInt32(placePopulation))
                {
                    PlaceService.SavePlace(_placeStreet, _placePopulation, Id_City, Place_Id_Building, Place_Id);
                }

                if (_placeStreet != placeStreet)
                {
                    PlaceService.SavePlace(_placeStreet, _placePopulation, Id_City, Place_Id_Building);
                }
            }
            else
            {
                CountryService.SaveCountry(_countryName, _countryContinent);
                int id_Country = CountryService.GetCountry().Select(x => x.Id).LastOrDefault();
                PresidentService.SavePresident(_presidentName, Convert.ToInt32(_presidentAge), id_Country);
                CityService.SaveCity(_cityName, Convert.ToInt32(_cityPopulation), id_Country);
                int id_City = CityService.GetCity().Select(x => x.Id).LastOrDefault();

                BuildingService.SaveBuilding(_buildingType, _buildingWindowsBool, _buildingIndustrialBool);
                Place_Id_Building = BuildingService.GetBuilding().Select(x => x.Id).LastOrDefault();
                PlaceService.SavePlace(_placeStreet, Convert.ToInt32(_placePopulation), id_City, Place_Id_Building);
            }


            CountryComboBoxList();
            PresidentComboBoxList();
            CityComboBoxList();
            PlaceComboBoxList();
            BuildingComboBoxList();
            CountrySetName.Clear();
            CountrySetContinent.Clear();
            PresidentSetName.Clear();
            PresidentSetAge.Clear();
            CitySetName.Clear();
            CitySetPopulation.Clear();
            CitySetPopulation.Clear();
            PlaceSetStreet.Clear();
            PlaceSetPopulation.Clear();
            BuildingSetType.Clear();
            BuildingSetWindows.Clear();
            BuildingSetIsIndustrial.Clear();
        }
Ejemplo n.º 3
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            string _countryName        = CountrySetName.Text;
            string _countryContinent   = CountrySetContinent.Text;
            string _presidentName      = PresidentSetName.Text;
            string _presidentAge       = PresidentSetAge.Text;
            string _cityName           = CitySetName.Text;
            string _cityPopulation     = CitySetPopulation.Text;
            string _palceStreet        = PlaceSetStreet.Text;
            string _placePopulation    = PlaceSetPopulation.Text;
            string _buildingType       = BuildingSetType.Text;
            string _buildingWindows    = BuildingSetWindows.Text;
            string _buildingIndustrial = BuildingSetIsIndustrial.Text;

            //if(_countryName==""||)


            if ((_countryName == countryName && _countryContinent != countryContinent) || (_countryName == countryName && _countryContinent == countryContinent))
            {
                CountryService.SaveCountry(_countryName, _countryContinent, Id_Country); //bez sensu. nawet jak nie zmieniam country to męczy DB i updatuje

                if ((_presidentName == presidentName && _presidentAge != presidentAge) || _presidentName != presidentName)
                {
                    PresidentService.SavePresident(_presidentName, Convert.ToInt32(_presidentAge), Id_Country);
                }
                if (_cityName != "")
                {
                    CityService.SaveCity(_cityName, Convert.ToInt32(_cityPopulation), Id_Country, Id_City);
                }
            }
            if (_countryName != countryName)
            {
                bool _buildingWindowsBool;
                bool _buildingIndustrialBool;
                CountryService.SaveCountry(_countryName, _countryContinent);
                int id_Country = CountryService.GetCountry().Select(x => x.Id).LastOrDefault();
                PresidentService.SavePresident(_presidentName, Convert.ToInt32(_presidentAge), id_Country);
                CityService.SaveCity(_cityName, Convert.ToInt32(_cityPopulation), id_Country);
                int id_City = CityService.GetCity().Select(x => x.Id).LastOrDefault();
                if (_buildingWindows.ToUpper().Trim() == "TAK")
                {
                    _buildingWindowsBool = true;
                }
                else
                {
                    _buildingWindowsBool = false;
                }
                if (_buildingIndustrial.ToUpper().Trim() == "TAK")
                {
                    _buildingIndustrialBool = true;
                }
                else
                {
                    _buildingIndustrialBool = false;
                }
                BuildingService.SaveBuilding(_buildingType, _buildingWindowsBool, _buildingIndustrialBool);
                int id_Building = BuildingService.GetBuilding().Select(x => x.Id).LastOrDefault();
                PlaceService.SavePlace(_palceStreet, Convert.ToInt32(_placePopulation), id_City, id_Building);
            }

            CountryComboBoxList();
            PresidentComboBoxList();
            CityComboBoxList();
            PlaceComboBoxList();
            BuildingComboBoxList();
            CountrySetName.Clear();
            CountrySetContinent.Clear();
            PresidentSetName.Clear();
            PresidentSetAge.Clear();
            CitySetName.Clear();
            CitySetPopulation.Clear();
            CitySetPopulation.Clear();
            PlaceSetStreet.Clear();
            PlaceSetPopulation.Clear();
            BuildingSetType.Clear();
            BuildingSetWindows.Clear();
            BuildingSetIsIndustrial.Clear();
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> GetBuilding(int id)
        {
            var res = await BuildingService.GetBuilding(_context, id);

            return(new ObjectResult(res));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> GetBuildingbyId(int id)
        {
            var building = await _buildingService.GetBuilding(id);

            return(Ok(building));
        }