private async void BtnCreate_Click(object sender, RoutedEventArgs e)
        {
            RealEstate realEstate = RealEstateFactory.addRealEstate(
                (Location)Enum.Parse(typeof(Location), cbxLocation.SelectedItem.ToString()),
                (RealEstateType)Enum.Parse(typeof(RealEstateType), cbxTypes.SelectedItem.ToString()),
                Convert.ToDouble(txtSquaremeter.Text, CultureInfo.InvariantCulture),
                Convert.ToInt32(txtRooms.Text),
                Convert.ToDouble(txtGardenSquaremeter.Text, CultureInfo.InvariantCulture),
                Convert.ToInt32(txtParkinglots.Text));

            if (realEstate != null)
            {
                txtResult.Text = "Result: \n" + realEstate.ToString();
                string stringPayload = await Task.Run(() => JsonConvert.SerializeObject(new RealEstateModel(realEstate.GetType().Name, realEstate.getLocation().ToString(), realEstate.getRooms(), realEstate.getSquaremeter(), realEstate.getGarden_squaremeter(), realEstate.getNum_of_parkinglots())));

                StringContent       httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/json");
                HttpResponseMessage response    = await DAL.PostAsync(REST_URL, httpContent);

                if (response.IsSuccessStatusCode)
                {
                    btnShowInList.IsEnabled = true;
                }
                else
                {
                    btnShowInList.IsEnabled = false;
                }
            }
            else
            {
                txtResult.Text = "Not possible to create " + cbxTypes.SelectedItem.ToString() + " in " + cbxLocation.SelectedItem.ToString() + ".";
            }
        }
Пример #2
0
        public Board(IDice dice)
        {
            var deckFactory = new DeckFactory();

            var utilityFactory         = new UtilityFactory(this, dice);
            var railroadFactory        = new RailroadFactory(this);
            var realEstateFactory      = new RealEstateFactory(this);
            var cardLocationFactory    = new CardLocationFactory(deckFactory);
            var nullLocationFactory    = new NullLocationFactory();
            var genericLocationFactory = new GenericLocationFactory();

            Locations = new[]
            {
                genericLocationFactory.Create(LocationConstants.GoIndex, new DepositAction(MonopolyConstants.GoPayoutAmount), new DepositAction(MonopolyConstants.GoPayoutAmount)),
                realEstateFactory.Create(LocationConstants.MediterraneanAveIndex),
                cardLocationFactory.CreateCommunityChestLocation(LocationConstants.CommunityChestIndex1),
                realEstateFactory.Create(LocationConstants.BalticAveIndex),
                genericLocationFactory.Create(LocationConstants.IncomeTaxIndex, new IncomeTaxAction(MonopolyConstants.IncomeTaxRate, MonopolyConstants.IncomeTaxMaximumAmount)),
                railroadFactory.Create(LocationConstants.ReadingRailroadIndex),
                realEstateFactory.Create(LocationConstants.OrientalAveIndex),
                cardLocationFactory.CreateChanceLocation(LocationConstants.ChanceIndex1),
                realEstateFactory.Create(LocationConstants.VermontAveIndex),
                realEstateFactory.Create(LocationConstants.ConnecticutAveIndex),
                nullLocationFactory.Create(10),
                realEstateFactory.Create(LocationConstants.StCharlesPlaceIndex),
                utilityFactory.Create(LocationConstants.ElectricCompanyIndex),
                realEstateFactory.Create(LocationConstants.StatesAveIndex),
                realEstateFactory.Create(LocationConstants.VirginiaAveIndex),
                railroadFactory.Create(LocationConstants.PennsylvaniaRailroadIndex),
                realEstateFactory.Create(LocationConstants.StJamesPlaceIndex),
                cardLocationFactory.CreateCommunityChestLocation(LocationConstants.CommunityChestIndex2),
                realEstateFactory.Create(LocationConstants.TennesseeAveIndex),
                realEstateFactory.Create(LocationConstants.NewYorkAveIndex),
                nullLocationFactory.Create(20),
                realEstateFactory.Create(LocationConstants.KentuckyAveIndex),
                cardLocationFactory.CreateChanceLocation(LocationConstants.ChanceIndex2),
                realEstateFactory.Create(LocationConstants.IndianaAveIndex),
                realEstateFactory.Create(LocationConstants.IllinoisAveIndex),
                railroadFactory.Create(LocationConstants.BAndORailroadIndex),
                realEstateFactory.Create(LocationConstants.AtlanticAveIndex),
                realEstateFactory.Create(LocationConstants.VentnorAveIndex),
                utilityFactory.Create(LocationConstants.WaterWorksIndex),
                realEstateFactory.Create(LocationConstants.MarvinGardensIndex),
                genericLocationFactory.Create(LocationConstants.GoToJailIndex, new GoToJailAction()),
                realEstateFactory.Create(LocationConstants.PacificAveIndex),
                realEstateFactory.Create(LocationConstants.NorthCarolinaAveIndex),
                cardLocationFactory.CreateCommunityChestLocation(LocationConstants.CommunityChestIndex3),
                realEstateFactory.Create(LocationConstants.PennsylvaniaAveIndex),
                railroadFactory.Create(LocationConstants.ShortLineRailroadIndex),
                cardLocationFactory.CreateChanceLocation(LocationConstants.ChanceIndex3),
                realEstateFactory.Create(LocationConstants.ParkPlaceIndex),
                genericLocationFactory.Create(LocationConstants.LuxuryTaxIndex, new WithdrawAction(MonopolyConstants.LuxuryTaxAmount)),
                realEstateFactory.Create(LocationConstants.BoardwalkIndex)
            };
        }
        private void BtnShowDetails_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            RealEstateModel currentModel = (RealEstateModel)dtgRealEstates.SelectedItem;

            if (currentModel != null)
            {
                RealEstate realEstate = RealEstateFactory.addRealEstate(
                    (Location)Enum.Parse(typeof(Location), currentModel.Location),
                    (RealEstateType)Enum.Parse(typeof(RealEstateType), currentModel.Type),
                    currentModel.Squaremeter,
                    currentModel.Rooms,
                    currentModel.GardenSquaremeter,
                    currentModel.NumOfParkinglots
                    );
                NavigationService.Navigate(new Details(realEstate));
            }
        }