/// <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", ""); }
/// <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)); }
/// <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)); }