Beispiel #1
0
 public static IEnumerable <IranState> GetProvinces(ProvinceType type)
 {
     if (type.HasFlag(ProvinceType.Province))
     {
         foreach (var prov in Provinces)
         {
             yield return(prov);
         }
     }
     if (type.HasFlag(ProvinceType.Island))
     {
         foreach (var prov in Islands)
         {
             yield return(prov);
         }
     }
 }
Beispiel #2
0
        public bool SaveRestaurants(RestaurantInfo restInfo)
        {
            Restaurants items = GetRestaurantReviewsFromXml();

            List <Restaurants> restInfos = new List <Restaurants>();

            Restaurants newRest = new Restaurants();

            Restaurants restaurants = new Restaurants();

            foreach (var item in newRest.Restaurant)
            {
                string toString = restInfo.address.city;
                item.Address.city = toString;
                ProvinceType toString2 = restInfo.address.province;
                item.Address.province = toString2;
                string toString3 = restInfo.address.address;
                item.Address.address = toString3;
                string toString4 = restInfo.address.postalcode;
                item.Address.postalcode = toString4;

                item.Name         = restInfo.Name;
                item.Summary      = restInfo.Summary;
                item.Rating.Value = (byte)restInfo.Rating;
            }

            restInfos.Add(items);

            restInfos.Add(newRest);

            foreach (var item in restInfos)
            {
                restaurants = item;
            }

            string xmlFilePath = Path.GetFullPath("Data/restaurant_review.xml");

            using (FileStream xs = new FileStream(xmlFilePath, FileMode.Create))
            {
                XmlSerializer serializor = new XmlSerializer(typeof(Restaurants));
                serializor.Serialize(xs, items);
            }

            return(true);
        }
Beispiel #3
0
        public Restaurants UpdateRestaurants([FromBody] RestaurantInfo restInfo)
        {
            int Id = restInfo.Id;

            Restaurants items = GetRestaurantReviewsFromXml();

            var curId = 0;

            foreach (var item in items.Restaurant)
            {
                if (Id == curId)
                {
                    string toString = restInfo.address.city;
                    item.Address.city = toString;
                    ProvinceType toString2 = restInfo.address.province;
                    item.Address.province = toString2;
                    string toString3 = restInfo.address.address;
                    item.Address.address = toString3;
                    string toString4 = restInfo.address.postalcode;
                    item.Address.postalcode = toString4;

                    item.Name         = restInfo.Name;
                    item.Summary      = restInfo.Summary;
                    item.Rating.Value = (byte)restInfo.Rating;
                }
                curId = curId + 1;
            }

            string xmlFilePath = Path.GetFullPath("Data/restaurant_review.xml");

            using (FileStream xs = new FileStream(xmlFilePath, FileMode.Create))
            {
                XmlSerializer serializor = new XmlSerializer(typeof(Restaurants));
                serializor.Serialize(xs, items);
            }

            return(items);
        }
Beispiel #4
0
 /// <summary>Creates a new <see cref="Province"/> instance.
 /// </summary>
 /// <param name="name">Name.</param>
 /// <param name="type">Type.</param>
 public Province(string name, ProvinceType type)
 {
     this.name = name;
     this.type = type;
     this.locations = new LocationCollection();
     this.adjacentProvinces = new ProvinceCollection();
 }