File size: 1,703 Bytes
e26fba6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Collections.Specialized;
using System.Reflection;

namespace MovieFinder.Client
{
    public partial class SuggestionForm : Form
    {
        public SuggestionForm()
        {
            InitializeComponent();
        }

        private void buttonClose_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void buttonSubmit_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(this.textBoxSuggestion.Text))
            {
                MessageBox.Show("Please enter your suggestion/bug", "Movie Finder");
                return;
            }
            try
            {
                PostResource(this.textBoxSuggestion.Text.Trim());
                MessageBox.Show("Thank you for your suggestion!!", "Movie Finder");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to send. Error: " + ex.Message, "Movie Finder");
            }

        }

        private void PostResource(string text)
        {

            using (var client = new WebClient())
            {
                var data = new NameValueCollection();
                data.Add("text", text);
                data.Add("version", Assembly.GetExecutingAssembly().GetName().Version.ToString());
                client.UploadValues(UrlConstants.SuggestionUrl, "POST", data); 
            }

        }
    }
}