Пример #1
0
        public static async Task <string> AnswerScalingQuestionTask(string answer, string userId, string routeId, DependencyObject sender)
        {
            StaticMethod.ShowProgress(sender, "Submitting your answer", 0, true, true);

            string link = "http://voucherworld.azurewebsites.net/api/questions/scaling?userId=" + userId + "&placeId=" +
                          routeId + "&answer=" + answer;
            WebRequest request = WebRequest.Create(new Uri(link, UriKind.Absolute));

            request.ContentType = "application/x-www-form-urlencoded";
            request.Method      = "POST";

            //Stream postStream = await request.GetRequestStreamAsync();
            //string postData = "answer=" + answer;

            //byte[] byteArray = Encoding.UTF8.GetBytes(postData);
            //postStream.Write(byteArray, 0, byteArray.Length);
            //postStream.Close();

            WebResponse response = await request.GetResponseAsync();

            Stream       responseStream = response.GetResponseStream();
            StreamReader reader         = new StreamReader(responseStream, Encoding.UTF8);
            string       result         = reader.ReadToEnd();

            StaticMethod.ShowProgress(sender, "Submitting your answer", 0, true, false);

            return(result);
        }
Пример #2
0
        public static async Task <string> LoginTask(string userName, string password)
        {
            string temp = await StaticMethod.PostHttpAsString(
                "http://voucherworld.azurewebsites.net/api/users/signin?username="******"&password=" + password);


            try
            {
                JArray jArray = JArray.Parse(temp);
                StaticData.CurrentUser = jArray.ToObject <User>();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(temp);
        }