Esempio n. 1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Get" /> class.
 /// </summary>
 /// <param name="controllerName">Name of the controller.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="e">The e.</param>
 /// <param name="methodUrl">The method URL.</param>
 public Get(string controllerName, int id, DownloadStringCompletedEventHandler e = null, string methodUrl = "")
 {
     var api = new WebApi(controllerName);
     var webClient = new RapWebClient {CookieContainer = RapClientCookie.Current};
     webClient.DownloadStringCompleted += e;
     webClient.DownloadStringAsync(string.IsNullOrEmpty(methodUrl)
         ? new Uri(api.Get(id))
         : new Uri(api.GetByAction(id, methodUrl)));
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Post" /> class.
 /// </summary>
 /// <param name="controllerName">Name of the controller.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="e">The e.</param>
 /// <param name="actionName">Name of the action.</param>
 public Delete(string controllerName, int id, UploadStringCompletedEventHandler e = null, string actionName = "")
 {
     var api = new WebApi(controllerName);
     var webClient = new RapWebClient {CookieContainer = RapClientCookie.Current};
     webClient.UploadStringCompleted += e;
     webClient.UploadStringAsync(string.IsNullOrEmpty(actionName) ? 
         new Uri(api.Delete(id)) : 
         new Uri(api.DeleteByAction(id, actionName)), "DELETE", "");
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Post" /> class.
 /// </summary>
 /// <param name="controllerName">Name of the controller.</param>
 /// <param name="payLoad">The pay load.</param>
 /// <param name="e">The e.</param>
 /// <param name="methodUrl">The method URL after the controller name from web api.</param>
 public Post(string controllerName, object payLoad, UploadStringCompletedEventHandler e = null,
     string methodUrl = "")
 {
     var api = new WebApi(controllerName);
     var url = new Uri(api.Post() + methodUrl);
     var webClient = new RapWebClient {CookieContainer = RapClientCookie.Current};
     webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
     webClient.UploadStringCompleted += e;
     webClient.UploadStringAsync(url, "POST", JsonConvert.SerializeObject(payLoad));
 }
Esempio n. 4
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Put" /> class.
 /// </summary>
 /// <param name="controllerName">Name of the controller.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="payLoad">The pay load.</param>
 /// <param name="e">The e.</param>
 /// <param name="methodUrl">The method URL.</param>
 public Put(string controllerName, int id, object payLoad, UploadStringCompletedEventHandler e = null,
     string actionName = "")
 {
     var api = new WebApi(controllerName);
     var webClient = new RapWebClient {CookieContainer = RapClientCookie.Current};
     webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
     webClient.UploadStringCompleted += e;
     webClient.UploadStringAsync(string.IsNullOrEmpty(actionName) ?
         new Uri(api.Put(id)) :
         new Uri(api.PutByAction(id, actionName)), "PUT", JsonConvert.SerializeObject(payLoad));
 }