private void button2_Click(object sender, RoutedEventArgs e)
        {
            if (textBox4.Text == "")
            {
                textBlock11.Text = "Please provide solution";
                return;
            }
            var solution = new ViewSolution { Id = Convert.ToInt32(selectedId), Solution = textBox4.Text, SolutionBy = userId };
           
            DataContractJsonSerializer jsonData =
              new DataContractJsonSerializer(typeof(ViewSolution));
            MemoryStream memStream = new MemoryStream();
            //S2 : Write data into Memory Stream
            jsonData.WriteObject(memStream, solution);
            //S3 : Read the bytes from Stream do that it can then beconverted to JSON String 
            byte[] jsonDataToPost = memStream.ToArray();
            memStream.Close();
            //S4: Ehencode the stream into string format
            var data = Encoding.UTF8.GetString(jsonDataToPost, 0, jsonDataToPost.Length);

            var api = "http://knowledgeshare.azurewebsites.net/api/solution";
            WebClient webClient, webClientSolution;
            webClientSolution = new WebClient();
            webClientSolution.UploadStringCompleted +=
        new UploadStringCompletedEventHandler(webClientSolution_OpenWriteCompleted);
            webClientSolution.Headers["content-type"] = "application/json";
            webClientSolution.UploadStringAsync(new Uri(api), "POST", data);
        }
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            if (textBox2.Text == "" || textBox4.Text == "")
            {
                textBlock7.Text = "Please fill in Zid and Problem";
                return;
            }
            var expert = new ViewSolution()
            {
                Course = textBox6.Text,
                FirstName = textBox1.Text,
                Zid = textBox2.Text,
                Email = textBox3.Text,  
                LastName = UserDetails.LastName,
                ProblemDescription = textBox4.Text,               
                Id = 0
            };

            //S1: Generate the JSON Serializer Data
            DataContractJsonSerializer jsonData =
                new DataContractJsonSerializer(typeof(ViewSolution));
            MemoryStream memStream = new MemoryStream();
            //S2 : Write data into Memory Stream
            jsonData.WriteObject(memStream, expert);
            //S3 : Read the bytes from Stream do that it can then beconverted to JSON String 
            byte[] jsonDataToPost = memStream.ToArray();
            memStream.Close();
            //S4: Ehencode the stream into string format
            var data = Encoding.UTF8.GetString(jsonDataToPost, 0, jsonDataToPost.Length);

            var api = "http://knowledgeshare.azurewebsites.net/api/problem";
            WebClient webClient, webClientSolution;
            webClientSolution = new WebClient();
            webClientSolution.UploadStringCompleted +=
        new UploadStringCompletedEventHandler(webClientSolution_OpenWriteCompleted);
            webClientSolution.Headers["content-type"] = "application/json";
            webClientSolution.UploadStringAsync(new Uri(api), "POST", data);
        }