예제 #1
0
    protected void btnARegister_Click(object sender, EventArgs e)
    {
        string imagefile = "notavailable.jpg";

        if (FileUpload2.HasFile) //checking whether the file upload has the file
        {
            imagefile = FileUpload2.FileName;
            FileUpload2.SaveAs(Server.MapPath("~/images/" + imagefile));//store the file in the images folder
        }
        //attraction
        Attraction a = new Attraction()
        {
            OrgEmail     = tbxAEmail.Text,
            Name         = tbxAName.Text,
            RegID        = tbxARegID.Text,
            Address      = tbxAddressA.Text,
            PostalCode   = tbxAPostalCode.Text,
            City         = tbxACity.Text,
            Country      = tbxACountry.Text,
            Password     = tbxAPassword.Text,
            ContactNo    = tbxAPhone.Text,
            Description  = "Not Applicable",
            StarRating   = Convert.ToInt32(5),
            OpeningHours = tbxAHour.Text,
            Photo        = imagefile,
            Verification = false
        };
        int id = AttractionDB.insertAttraction(a);

        lblOutput.Text = id + "Registered Successfully!";
    }
예제 #2
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string userinput = tbxInput.Text;

        using (WebClient wc = new WebClient())
        {
            var json = wc.DownloadString("https://maps.googleapis.com/maps/api/place/textsearch/json?query=" + tbxInput.Text + "&key=AIzaSyA-Brzltyb6U-xbPlQyCUM2n4F_c130xl0");
            //tbxOutput.Text = json;
            JObject jt     = JObject.Parse(json);
            JToken  c      = jt.GetValue("results");
            String  output = "";
            foreach (var result in c)
            {
                output += result.Value <string>("formatted_address").ToString() + Environment.NewLine;
                output += result.Value <string>("name").ToString() + Environment.NewLine;
                output += result.Value <int>("rating") + Environment.NewLine;

                Attraction a = new Attraction()
                {
                    OrgEmail     = "",
                    Name         = result.Value <string>("name").ToString(),
                    RegID        = "",
                    Address      = result.Value <string>("formatted_address").ToString(),
                    PostalCode   = "",
                    City         = "",
                    Country      = "",
                    Password     = "******",
                    ContactNo    = "",
                    Description  = "Not Applicable",
                    StarRating   = Convert.ToInt32(5),
                    OpeningHours = "",
                    Photo        = "",
                    Verification = true
                };

                int id = AttractionDB.insertAttraction(a);
                lblOutput.Text = id + "Registered Successfully!";
            }
            tbxOutput.Text = output;
        }
    }