Example #1
0
		public WebService ()
		{
			CurrentOrder = new Order ();
		}
Example #2
0
		public Task<OrderResult> PlaceOrder (User user, bool verify = false) {
			return Task.Factory.StartNew (() => {
				try {
					var content = Encoding.UTF8.GetBytes (CurrentOrder.GetJson (user));

					var request = CreateRequest ("order" + (verify ? "?verify=1" : ""));
					request.Method = "POST";
					request.ContentLength = content.Length;

					using (Stream s = request.GetRequestStream ()) {
						s.Write (content, 0, content.Length);
					}
					string response = ReadResponseText (request);
					var result = Newtonsoft.Json.JsonConvert.DeserializeObject<OrderResult> (response);
					if(!verify && result.Success)
						CurrentOrder = new Order();
					return result;
				} catch (Exception ex) {
					return new OrderResult {
						Success = false,
						Message = ex.Message,
					};
				}
			});
		}
Example #3
0
 public BasketFragment(Order order)
 {
     _order = order;
 }