protected void Page_Load(object sender, EventArgs e)
    {
        restaurants allRestaurants = null;

        if (Session["allRestaurants"] == null)
        {
            string xmlFile = MapPath(@"~/restaurant-reviews.xml");
            using (FileStream fs = new FileStream(xmlFile, FileMode.Open))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(restaurants));
                allRestaurants = (restaurants)serializer.Deserialize(fs);
            }
            Session["allRestaurants"] = allRestaurants;
        }
        else
        {
            allRestaurants = Session["allRestaurants"] as restaurants;
        }
        if (!IsPostBack)
        {
            drpRestaurants.DataSource    = allRestaurants.restaurant;
            drpRestaurants.DataTextField = "name";
            drpRestaurants.DataBind();
            drpRestaurants.Items.Insert(0, new ListItem("Please select one...", "0"));
            drpRestaurants.Visible = true;
            details.Visible        = false;
        }
    }
Exemple #2
0
        public bool SaveRestaurant(RestaurantInfo restInfo)
        {
            bool        saveResult     = false;
            restaurants allRestaurants = GetRestaurantsFormXml();


            for (int i = 0; i < allRestaurants.restaurant.Length; i++)
            {
                if (allRestaurants.restaurant[i].name == restInfo.Name)
                {
                    allRestaurants.restaurant[i].summary = restInfo.Summary;

                    allRestaurants.restaurant[i].rating = restInfo.Rating;

                    allRestaurants.restaurant[i].location.street        = restInfo.Location.Street;
                    allRestaurants.restaurant[i].location.city          = restInfo.Location.City;
                    allRestaurants.restaurant[i].location.provstate     = restInfo.Location.Province;
                    allRestaurants.restaurant[i].location.postalzipcode = restInfo.Location.PostalCode;

                    saveResult = true;
                }
            }


            XmlSerializer serializor = new XmlSerializer(typeof(restaurants));
            XmlTextWriter tw         = new XmlTextWriter("C:/temp/restaurant_reviews.xml", Encoding.UTF8);

            serializor.Serialize(tw, allRestaurants);
            tw.Close();

            return(saveResult);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        restaurants restaurantList = null;

        if (Session ["restaurantListSession"] == null) //in case there is no session yet
        {
            //opening the xml file
            string xmlFile = MapPath(@"~/restaurant_reviews.xml");
            using (FileStream xs = new FileStream(xmlFile, FileMode.Open))
            {
                //deserializing the file (converting it into an object)
                XmlSerializer serial = new XmlSerializer(typeof(restaurants));
                restaurantList = (restaurants)serial.Deserialize(xs);
            }
            Session["restaurantListSession"] = restaurantList;
        }
        else
        {
            restaurantList = Session["restaurantListSession"] as restaurants;
        }

        if (!IsPostBack) //if loading for the first time, display restaurant list using DataBinding:
        {
            //code added for lab8:
            //RestaurantReviewService reviewer = new RestaurantReviewService();
            RestaurantServiceClient reviewer = new RestaurantServiceClient();
            string[] restaurantNames         = reviewer.GetRestaurantNames();
            restaurantDropDown.DataSource = restaurantNames;

            restaurantDropDown.DataBind();
            restaurantDropDown.Items.Insert(0, new ListItem("Select One...", "0"));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //Use the names of the restaurants in the XML file  to populate the dropdown list

            restaurants allRestaurants = deserialize_xml();

            drpRestaurants.Items.Add("--Select One");

            foreach (restaurant restaurant in allRestaurants.restaurant)
            {
                drpRestaurants.Items.Add(restaurant.name.ToString());

                txtAddress.Text = null;
                txtAddress.Attributes.Add("readonly", "readonly");

                txtCity.Text = null;
                txtCity.Attributes.Add("readonly", "readonly");

                txtProvinceState.Text = null;
                txtProvinceState.Attributes.Add("readonly", "readonly");

                txtPostalZipCode.Text = null;
                txtPostalZipCode.Attributes.Add("readonly", "readonly");

                txtSummary.Text = null;
                txtSummary.Attributes.Add("readonly", "readonly");

                drpRating.Style.Add("display", "none");
            }
        }
    }
        public RestaurantInfo GetRestaurantByName(string name)
        {
            restaurants all_restaurants = GetRestaurantsFromXml();

            if (all_restaurants != null)
            {
                foreach (restaurant restaurant in all_restaurants.restaurant)
                {
                    if (restaurant.name == name)
                    {
                        var restaurant_info = new RestaurantInfo
                        {
                            Name     = restaurant.name,
                            Rating   = restaurant.rating.ToString(),
                            Summary  = restaurant.summary,
                            Location = new Address
                            {
                                Street     = restaurant.location.street,
                                City       = restaurant.location.city,
                                Province   = restaurant.location.provstate,
                                PostalCode = restaurant.location.postalzipcode
                            }
                        };
                        return(restaurant_info);
                    }
                }
            }
            // return empty RestaurantInfo is name not found
            return(new RestaurantInfo());
        }
Exemple #6
0
        public List <RestaurantInfo> GetRestaurantsByRating(int rating)
        {
            restaurants           allRestauants = GetRestaurantsFromXml();
            List <RestaurantInfo> restInfos     = new List <RestaurantInfo>();

            foreach (restaurant rest in allRestauants.restaurant)
            {
                if (rest.rating >= rating)
                {
                    RestaurantInfo restInfo = new RestaurantInfo();
                    restInfo.Name    = rest.name;
                    restInfo.Summary = rest.summary;
                    restInfo.Rating  = rest.rating;

                    restInfo.Location            = new Address();
                    restInfo.Location.Street     = rest.location.street;
                    restInfo.Location.City       = rest.location.city;
                    restInfo.Location.Province   = rest.location.provstate.ToString();
                    restInfo.Location.PostalCode = rest.location.postalzipcode;

                    restInfos.Add(restInfo);
                }
            }
            return(restInfos);
        }
    protected void saveBtn_Click(object sender, EventArgs e)
    {
        //creating a restaurants object from the session
        restaurants restaurantList = Session["restaurantListSession"] as restaurants;

        if (restaurantDropDown.SelectedValue != "0") //if there is a restaurant selected
        {
            //create a restaurant object for the selected restaurant and displayin its info
            restaurantsRestaurant rest = restaurantList.restaurant[restaurantDropDown.SelectedIndex - 1];
            rest.summary      = summaryTxt.Text;
            rest.rating.Value = byte.Parse(ratingDropDown.SelectedValue);

            //creating a string from the xml file
            string xmlFile = MapPath(@"~/restaurant_reviews.xml");

            // serializing (converting from object to xml) the file:
            using (FileStream xs = new FileStream(xmlFile, FileMode.Create))
            {
                XmlSerializer serializor = new XmlSerializer(typeof(restaurants));
                serializor.Serialize(xs, restaurantList);
            }

            //text message at the bottle
            messageLbl.Visible = true;
            messageLbl.Text    = "Revised retaurant review has been saved to " + xmlFile;
        }
    }
    protected void restaurantDropDown_SelectedIndexChanged(object sender, EventArgs e)
    {
        //creating a list of restaurants from the data stored in the session from xml file
        restaurants restaurantList = Session["restaurantListSession"] as restaurants;

        //displaying additional fields when there's something selected from dropdown list:
        if (restaurantDropDown.SelectedValue == "0")
        {
            addressLbl.Visible     = false;
            addressTxt.Visible     = false;
            summaryLbl.Visible     = false;
            summaryTxt.Visible     = false;
            ratingLbl.Visible      = false;
            ratingDropDown.Visible = false;
            saveBtn.Visible        = false;
            return;
        }
        else
        {
            addressLbl.Visible     = true;
            addressTxt.Visible     = true;
            summaryLbl.Visible     = true;
            summaryTxt.Visible     = true;
            addressTxt.Enabled     = false;
            ratingLbl.Visible      = true;
            ratingDropDown.Visible = true;
            saveBtn.Visible        = true;
            //calling function to display info on each restaurant
            displayRestaurantInfo(restaurantList.restaurant[restaurantDropDown.SelectedIndex - 1]);
        }
    }
Exemple #9
0
        public bool SaveRestaurant(RestaurantInfo restInfo)
        {
            restaurants allRestaurants = GetRestaurantsFromXml();

            foreach (restaurant rest in allRestaurants.restaurant)
            {
                if (rest.name == restInfo.Name)
                {
                    rest.summary                = restInfo.Summary;
                    rest.rating                 = restInfo.Rating;
                    rest.location.street        = restInfo.Location.Street;
                    rest.location.city          = restInfo.Location.City;
                    rest.location.provstate     = restInfo.Location.Province;
                    rest.location.postalzipcode = restInfo.Location.PostalCode;

                    XmlSerializer serializor = new XmlSerializer(typeof(restaurants));
                    string        xmlFile    = System.Web.HttpContext.Current.Server.MapPath(@"~/App_Data/restaurant_reviews.xml");

                    XmlTextWriter tw = new XmlTextWriter(xmlFile, Encoding.UTF8);
                    serializor.Serialize(tw, allRestaurants);
                    tw.Close();
                    return(true);
                }
            }
            return(false);
        }
        public bool SaveRestaurant(RestaurantInfo restaurant_info)
        {
            restaurants all_restaurants = GetRestaurantsFromXml();
            restaurant  selected_restaurant;

            foreach (restaurant rest in all_restaurants.restaurant)
            {
                if (rest.name == restaurant_info.Name)
                {
                    selected_restaurant = rest;
                    string xmlFile = HttpContext.Current.Server.MapPath(@"App_Data/restaurant_reviews.xml");
                    selected_restaurant.summary                = restaurant_info.Summary;
                    selected_restaurant.rating                 = int.Parse(restaurant_info.Rating);
                    selected_restaurant.location.street        = restaurant_info.Location.Street;
                    selected_restaurant.location.postalzipcode = restaurant_info.Location.PostalCode;
                    selected_restaurant.location.provstate     = restaurant_info.Location.Province;
                    selected_restaurant.location.city          = restaurant_info.Location.City;
                    using (FileStream xs = new FileStream(xmlFile, FileMode.Create))
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(restaurants));
                        serializer.Serialize(xs, all_restaurants);
                    }
                    return(true);
                }
            }
            return(false);
        }
        //There is no need to pass an id in when the id is in the restaurants object.
        public void Update(restaurants restaurant)
        {
            restaurants restaurantToUpdate = Read(restaurant.id);

            restaurantToUpdate.city_id          = restaurant.city_id;
            restaurantToUpdate.cuisine_id       = restaurant.cuisine_id;
            restaurantToUpdate.cuisines         = restaurant.cuisines;
            restaurantToUpdate.currency         = restaurant.currency;
            restaurantToUpdate.establishment    = restaurant.establishment;
            restaurantToUpdate.has_delivery     = restaurant.has_delivery;
            restaurantToUpdate.has_takeaway     = restaurant.has_takeaway;
            restaurantToUpdate.address          = restaurant.address;
            restaurantToUpdate.city             = restaurant.city;
            restaurantToUpdate.state_code       = restaurant.state_code;
            restaurantToUpdate.locality         = restaurant.locality;
            restaurantToUpdate.locality_verbose = restaurant.locality_verbose;
            restaurantToUpdate.zip_code         = restaurant.zip_code;
            restaurantToUpdate.menu_url         = restaurant.menu_url;
            restaurantToUpdate.name             = restaurant.name;
            restaurantToUpdate.telephone        = restaurant.telephone;
            restaurantToUpdate.price_range      = restaurant.price_range;
            restaurantToUpdate.timings          = restaurant.timings;
            restaurantToUpdate.url = restaurant.url;
            restaurantToUpdate.aggregate_rating = restaurant.aggregate_rating;
            restaurantToUpdate.rating_text      = restaurant.rating_text;
            _db.SaveChanges();
        }
Exemple #12
0
        public RestaurantInfo GetRestaurantByName(string name)
        {
            restaurants allRestaurants = GetRestaurantsFormXml();

            RestaurantInfo restaurantInfo = new RestaurantInfo();
            Address        address        = new Address();

            for (int i = 0; i < allRestaurants.restaurant.Length; i++)
            {
                if (name == allRestaurants.restaurant[i].name)
                {
                    address.Street = allRestaurants.restaurant[i].location.street;

                    address.City = allRestaurants.restaurant[i].location.city;

                    address.Province = allRestaurants.restaurant[i].location.provstate;

                    address.PostalCode = allRestaurants.restaurant[i].location.postalzipcode;

                    restaurantInfo.Name    = allRestaurants.restaurant[i].name;
                    restaurantInfo.Summary = allRestaurants.restaurant[i].summary;

                    restaurantInfo.Rating   = allRestaurants.restaurant[i].rating;
                    restaurantInfo.Location = address;
                }
            }

            return(restaurantInfo);
        }
        public List <RestaurantInfo> GetRestaurantsByRating(int rating)
        {
            restaurants           all_restaurants = GetRestaurantsFromXml();
            List <RestaurantInfo> restaurant_info = new List <RestaurantInfo>();

            if (all_restaurants != null)
            {
                foreach (restaurant restaurant in all_restaurants.restaurant)
                {
                    if (restaurant.rating >= rating)
                    {
                        RestaurantInfo info = new RestaurantInfo
                        {
                            Name     = restaurant.name,
                            Rating   = restaurant.rating.ToString(),
                            Summary  = restaurant.summary,
                            Location = new Address
                            {
                                Street     = restaurant.location.street,
                                City       = restaurant.location.city,
                                Province   = restaurant.location.provstate,
                                PostalCode = restaurant.location.postalzipcode
                            }
                        };
                        restaurant_info.Add(info);
                    }
                }
                return(restaurant_info);
            }
            // return empty RestaurantInfo is name not found
            return(restaurant_info);
        }
Exemple #14
0
        public restaurants GetRestaurantsFormXml()
        {
            FileStream    xs         = new FileStream("C:/temp/restaurant_reviews.xml", FileMode.Open);//1+2
            XmlSerializer serializor = new XmlSerializer(typeof(restaurants));

            restaurants restaurnts = (restaurants)serializor.Deserialize(xs);

            xs.Close();
            return(restaurnts);
        }
Exemple #15
0
        public IActionResult CreateRestaurant(restaurants restaurant)
        {
            if (restaurant.has_delivery != 0 && restaurant.has_delivery != 0 && restaurant.establishment != "0")
            {
                _restaurantRepo.Create(restaurant);

                return(RedirectToAction("Index", "Home"));
            }
            return(View(restaurant));
        }
Exemple #16
0
        public IActionResult Edit(restaurants rest)
        {
            var check = _restaurantRepo.Read(rest.id);

            if (check != null)
            {
                _restaurantRepo.Update(rest);
                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("Index", "Home"));
        }
    protected void drpRestaurants_SelectedIndexChanged(object sender, EventArgs e)
    {
        //show the selected restaurant data as specified in the lab requirements
        lblConfirmation.Visible = false;

        restaurants allRestaurants = deserialize_xml();

        string selectedRestaurant = null;

        selectedRestaurant = drpRestaurants.SelectedValue;

        foreach (restaurant restaurant in allRestaurants.restaurant)
        {
            if (restaurant.name == selectedRestaurant)
            {
                txtAddress.Text = restaurant.location.street.ToString();
                txtAddress.Attributes.Add("readonly", "readonly");

                txtCity.Text = restaurant.location.city.ToString();
                txtCity.Attributes.Add("readonly", "readonly");

                txtProvinceState.Text = restaurant.location.provstate.ToString();
                txtProvinceState.Attributes.Add("readonly", "readonly");

                txtPostalZipCode.Text = restaurant.location.postalzipcode.ToString();
                txtPostalZipCode.Attributes.Add("readonly", "readonly");

                txtSummary.Text = restaurant.summary.ToString();
                txtSummary.Attributes.Remove("readonly");

                drpRating.Style.Remove("display");
                drpRating.SelectedValue = restaurant.rating.ToString();
            }
            else if ("--Select One" == selectedRestaurant)
            {
                txtAddress.Text = null;
                txtAddress.Attributes.Add("readonly", "readonly");

                txtCity.Text = null;
                txtCity.Attributes.Add("readonly", "readonly");

                txtProvinceState.Text = null;
                txtProvinceState.Attributes.Add("readonly", "readonly");

                txtPostalZipCode.Text = null;
                txtPostalZipCode.Attributes.Add("readonly", "readonly");

                txtSummary.Text = null;
                txtSummary.Attributes.Add("readonly", "readonly");

                drpRating.Style.Add("display", "none");
            }
        }
    }
        static void checkReservation(int userId)
        {
            Console.WriteLine("These are your current reservation:\n");

            // List die uit reservatie class objecten bestaat
            List <reservation> userReservations = new List <reservation>();

            //Connectie string
            SqlConnection connection = new SqlConnection("Data Source=luxefood.database.windows.net;Initial Catalog=LuxeFoods;User ID=Klees;Password=Johnny69;Connect Timeout=60;Encrypt=True;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False");

            // SQL command om alle reserveringen met de gegeven KlantId te geven
            SqlCommand readCommand = new SqlCommand("select * from reservering where klantId='" + userId + "'", connection);

            connection.Open();
            using (SqlDataReader reader = readCommand.ExecuteReader())
            {
                while (reader.Read())
                {
                    // Al de gegeven reserveringen in een object zetten en dan in de List opslaan
                    reservation _ = new reservation(reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2), reader.GetDateTime(3), reader.GetInt32(4));
                    userReservations.Add(_);
                }

                // Connectie met database beindigen
                connection.Close();
            }

            List <restaurants> allRestaurants = new List <restaurants>();

            // SQL Command om alle restaurant data te krijgen
            SqlCommand restReadCommand = new SqlCommand("select * from restaurant", connection);

            connection.Open();
            using (SqlDataReader reader = restReadCommand.ExecuteReader())
            {
                while (reader.Read())
                {
                    // Alle restaurant info in een object zetten en in de list opslaan
                    restaurants _ = new restaurants(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(3));
                    allRestaurants.Add(_);
                }

                // Connectie met database beindigen
                connection.Close();
            }

            // Alle reservering van deze user uitprinten format(id:tt tttt yyyy-mm-dd hh-mm-ss tt)
            foreach (reservation x in userReservations)
            {
                Console.WriteLine("id: " + x.Id + " " + allRestaurants[x.restaurantId - 1].Naam + " " + x.Date + " Gereserveerde Tafels: " + x.tableNr);
            }
        }
Exemple #19
0
        // Function to get the list of restaurants from XML file
        public restaurants GetRestaurantsFromXml()
        {
            restaurants restaurantList = null;
            string      xmlFile        = HttpContext.Current.Server.MapPath(@"App_Data/restaurant_reviews.xml");

            //opening the xml file and deserializing it (converting xml file into object)
            using (FileStream xs = new FileStream(xmlFile, FileMode.Open))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(restaurants));
                restaurantList = (restaurants)serializer.Deserialize(xs);
            }
            return(restaurantList);
        }
Exemple #20
0
        protected restaurants GetRestaurantsFromXml()
        {
            string xmlFile = System.Web.HttpContext.Current.Server.MapPath(@"~/App_Data/restaurant_reviews.xml");

            FileStream xs = new FileStream(xmlFile, FileMode.Open);

            XmlSerializer serializor = new XmlSerializer(typeof(restaurants));

            restaurants allRestaurants = (restaurants)serializor.Deserialize(xs);

            xs.Close();

            return(allRestaurants);
        }
        public List <string> GetRestaurantNames()
        {
            List <string> names           = new List <string>();
            restaurants   all_restaurants = GetRestaurantsFromXml();

            if (all_restaurants != null)
            {
                foreach (restaurant restaurant in all_restaurants.restaurant)
                {
                    names.Add(restaurant.name.ToString());
                }
            }
            return(names);
        }
        public restaurants GetRestaurantsFromXml()
        {
            //function for deserializing xml
            string      xmlFile        = HttpContext.Current.Server.MapPath(@"App_Data/restaurant_reviews.xml");
            restaurants restaurantList = null;

            //Opening XML file and serializing into classes
            using (FileStream xs = new FileStream(xmlFile, FileMode.Open))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(restaurants));
                restaurantList = (restaurants)serializer.Deserialize(xs);
            }
            return(restaurantList);
        }
    public restaurants deserialize_xml()
    {
        //function for deserializing xml
        string xmlString = @MapPath("~/App_Data/restaurant_reviews.xml");

        FileStream xs = new FileStream(xmlString, FileMode.Open);

        XmlSerializer serializor = new XmlSerializer(typeof(restaurants));

        restaurants allRestaurants = (restaurants)serializor.Deserialize(xs);

        xs.Close();

        return(allRestaurants);
    }
    protected void drpRestaurants_SelectedIndexChanged(object sender, EventArgs e)
    {
        restaurants allRestaurants = Session["allRestaurants"] as restaurants;

        if (drpRestaurants.SelectedValue == "0")
        {
            drpRestaurants.Visible = true;
            details.Visible        = false;
            return;
        }
        else
        {
            drpRestaurants.Visible = true;
            ShowRestaurant(allRestaurants.restaurant[drpRestaurants.SelectedIndex - 1]);
        }
    }
Exemple #25
0
        public List <string> GetRestaurantNames()
        {
            List <string> names = new List <string>();

            restaurants allRestaurants = GetRestaurantsFormXml();

            if (allRestaurants != null)
            {
                foreach (restaurant rest in allRestaurants.restaurant)
                {
                    names.Add(rest.name);
                } //foreach
            }     //if

            return(names);
        }
        public void Delete(int id)
        {
            restaurants check = Read(id);

            if (check != null)
            {
                List <reviews> reviews    = ReadReviewsByRestId(id);
                covid19        covidStuff = ReadRestPol(id);

                _db.Reviews.RemoveRange(reviews);
                _db.Covid19.Remove(covidStuff);
                _db.Restaurants.Remove(check);
                //_db.Remove(check);
                _db.SaveChanges();
            }
        }
    protected void btnSaveChanges_Click(object sender, EventArgs e)
    {
        restaurants allRestaurants = Session["allRestaurants"] as restaurants;

        if (drpRestaurants.SelectedValue != "0")
        {
            restaurant r = allRestaurants.restaurant[drpRestaurants.SelectedIndex - 1];
            r.summary      = txtSummary.Text;
            r.rating.Value = decimal.Parse(drpRating.SelectedValue);
            string xmlFile = MapPath(@"~/restaurant-reviews.xml");
            using (FileStream fs = new FileStream(xmlFile, FileMode.Create))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(restaurants));
                serializer.Serialize(fs, allRestaurants);
            }
            lblConfirmation.Visible = true;
            lblConfirmation.Text    = "Revised Restaurant Review has been saved to" + xmlFile;
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        //Save the changed restaurant restaurant data back to the XML file.

        string xmlFile = @MapPath("~/App_Data/restaurant_reviews.xml");

        restaurants allRestaurants = deserialize_xml();

        string summaryValue = txtSummary.Text;
        int    ratingValue  = Convert.ToInt32(drpRating.SelectedValue);


        string selectedRestaurant = null;

        selectedRestaurant = drpRestaurants.SelectedValue;



        foreach (restaurant restaurant in allRestaurants.restaurant)
        {
            if (restaurant.name == selectedRestaurant)
            {
                restaurant.summary = summaryValue;
                restaurant.rating  = ratingValue;

                FileStream    xs         = new FileStream(xmlFile, FileMode.Create);
                XmlSerializer serializer = new XmlSerializer(typeof(restaurants));
                serializer.Serialize(xs, allRestaurants);

                xs.Close();
            }
        }

        if (drpRestaurants.Text != "--Select One")
        {
            string confirmationString = "Changes have been made too " + xmlFile;
            lblConfirmation.Text    = confirmationString;
            lblConfirmation.Visible = true;
        }
    }
Exemple #29
0
        public List <RestaurantInfo> GetRestaurantsByRating(int rating)
        // public RestaurantInfo[] GetRestaurantsByRating(int rating)

        {
            restaurants allRestaurants = GetRestaurantsFormXml();


            //RestaurantInfo[]  restaurantsInfo = new RestaurantInfo[2];

            List <RestaurantInfo> restaurantsInfo = new List <RestaurantInfo>();

            for (int i = 0; i < allRestaurants.restaurant.Length; i++)
            {
                if (allRestaurants.restaurant[i].rating >= rating)
                {
                    RestaurantInfo restaurantInfo = new RestaurantInfo();
                    Address        address        = new Address();


                    address.Street = allRestaurants.restaurant[i].location.street.ToString();

                    address.City = allRestaurants.restaurant[i].location.city.ToString();

                    address.Province = allRestaurants.restaurant[i].location.provstate;

                    address.PostalCode = allRestaurants.restaurant[i].location.postalzipcode.ToString();

                    restaurantInfo.Name    = allRestaurants.restaurant[i].name;
                    restaurantInfo.Summary = allRestaurants.restaurant[i].summary.ToString();

                    restaurantInfo.Rating   = allRestaurants.restaurant[i].rating;
                    restaurantInfo.Location = address;

                    restaurantsInfo.Add(restaurantInfo);
                }
            }

            return(restaurantsInfo);
        }
Exemple #30
0
        public RestaurantInfo GetRestaurantByName(string name)
        {
            restaurants allRestaurants = GetRestaurantsFromXml();

            foreach (restaurant rest in allRestaurants.restaurant)
            {
                if (rest.name == name)
                {
                    RestaurantInfo restInfo = new RestaurantInfo();
                    restInfo.Location = new Address();

                    restInfo.Name                = rest.name;
                    restInfo.Summary             = rest.summary;
                    restInfo.Rating              = rest.rating;
                    restInfo.Location.Street     = rest.location.street;
                    restInfo.Location.City       = rest.location.city;
                    restInfo.Location.Province   = rest.location.provstate;
                    restInfo.Location.PostalCode = rest.location.postalzipcode;
                    return(restInfo);
                }
            }
            return(null);
        }