Пример #1
0
 public ResidentialEstate(int estateID, Address address, EstateLegalForm estateLegalForm, int estatePrice, double estateDimensions, int estateRent) : base(estateID, address, estateLegalForm)
 {
     this.estatePrice      = estatePrice;
     this.estateDimensions = estateDimensions;
     this.estateRent       = estateRent;
     this.estateLegalForm  = estateLegalForm;
 }
Пример #2
0
 public Estate(int estateID, Address address, EstateLegalForm estateLegalForm)
 {
     this.estateID        = estateID;
     this.address         = address;
     this.estateType      = estateType;
     this.estateLegalForm = estateLegalForm;
 }
Пример #3
0
 public TownHouse(int estateID, Address address, EstateLegalForm estateLegalForm, int estatePrice, double estateDimensions, int estateRent) : base(estateID, address, estateLegalForm, estatePrice, estateDimensions, estateRent)
 {
     this.estateID         = estateID;
     this.address          = address;
     this.estateType       = EstateType.Townhouse;
     this.estateLegalForm  = estateLegalForm;
     this.estatePrice      = estatePrice;
     this.estateDimensions = estateDimensions;
     this.estateRent       = estateRent;
 }
Пример #4
0
        //Makes sure that no info is empty and then creates and adds and Estate to the list.
        public bool AddEstate(Address address, EstateType estateType, EstateLegalForm estateLegalForm, string estatePrice, string estateDimensions, string estateRent, string imageString)
        {
            Estate estate;

            if (String.IsNullOrEmpty(address.city) || String.IsNullOrEmpty(address.street) || String.IsNullOrEmpty(address.zipCode))
            {
                return(false);
            }

            if (int.TryParse(estatePrice, out int estatePriceResult) &&
                double.TryParse(estateDimensions, out double estateDimensionsResult) &&
                int.TryParse(estateRent, out int estateRentResult))
            {
                if (estateType == EstateType.Apartment)
                {
                    estate = new Apartment(GenerateEstateID(), address, estateLegalForm, estatePriceResult, estateDimensionsResult, estateRentResult);
                    estate.EstatePicture = imageString;
                    em.Add(estate);
                    SetChanged();
                    return(true);
                }
                else if (estateType == EstateType.House)
                {
                    estate = new House(GenerateEstateID(), address, estateLegalForm, estatePriceResult, estateDimensionsResult, estateRentResult);
                    estate.EstatePicture = imageString;
                    em.Add(estate);
                    SetChanged();
                    return(true);
                }
                else if (estateType == EstateType.Villa)
                {
                    estate = new Villa(GenerateEstateID(), address, estateLegalForm, estatePriceResult, estateDimensionsResult, estateRentResult);
                    estate.EstatePicture = imageString;
                    em.Add(estate);
                    SetChanged();
                    return(true);
                }
                else if (estateType == EstateType.Townhouse)
                {
                    estate = new TownHouse(GenerateEstateID(), address, estateLegalForm, estatePriceResult, estateDimensionsResult, estateRentResult);
                    estate.EstatePicture = imageString;
                    em.Add(estate);
                    SetChanged();
                    return(true);
                }
                else if (estateType == EstateType.Factory)
                {
                    estate = new Factory(GenerateEstateID(), address, estateLegalForm, estatePriceResult, estateDimensionsResult, estateRentResult);
                    estate.EstatePicture = imageString;
                    em.Add(estate);
                    SetChanged();
                    return(true);
                }
                else if (estateType == EstateType.Shop)
                {
                    estate = new Shop(GenerateEstateID(), address, estateLegalForm, estatePriceResult, estateDimensionsResult, estateRentResult);
                    estate.EstatePicture = imageString;
                    em.Add(estate);
                    SetChanged();
                    return(true);
                }
                else if (estateType == EstateType.Warehouse)
                {
                    estate = new Warehouse(GenerateEstateID(), address, estateLegalForm, estatePriceResult, estateDimensionsResult, estateRentResult);
                    estate.EstatePicture = imageString;
                    em.Add(estate);
                    SetChanged();
                    return(true);
                }
            }

            return(false);
        }
Пример #5
0
        //Modifies the chosen estate after verifying the ID.
        public bool ModifyEstate(string estateID, Countries country, string city, string street, string zipCode, EstateLegalForm estateLegalForm, string estatePrice, string estateDimensions, string estateRent, string imageString)
        {
            Estate estate = null;
            int    ID;
            bool   IDExists = ValidateID(estateID, out ID);

            if (!IDExists)
            {
                return(false);
            }

            foreach (Estate compareEstate in em.getList())
            {
                if (compareEstate.estateID == ID)
                {
                    estate = compareEstate;
                }
            }

            estate.address.country = country;
            estate.estateLegalForm = estateLegalForm;

            //Checks which fields are entered and only modifies those. Also cathces any parsing errors.
            try
            {
                if (!String.IsNullOrEmpty(city))
                {
                    estate.address.city = city;
                }
                if (!String.IsNullOrEmpty(street))
                {
                    estate.address.street = street;
                }
                if (!String.IsNullOrEmpty(zipCode))
                {
                    estate.address.zipCode = zipCode;
                }
                if (!String.IsNullOrEmpty(estateDimensions))
                {
                    estate.estateDimensions = double.Parse(estateDimensions);
                }
                if (!String.IsNullOrEmpty(estateRent))
                {
                    estate.estateRent = int.Parse(estateRent);
                }
                if (!String.IsNullOrEmpty(estatePrice))
                {
                    estate.estatePrice = int.Parse(estatePrice);
                }
                if (!String.IsNullOrEmpty(imageString))
                {
                    estate.EstatePicture = imageString;
                }
            }
            catch (Exception e)
            {
                return(false);
            }
            SetChanged();
            return(true);
        }