/// <summary> /// Gets the request URI. /// </summary> /// <param name="apiEndpoint">The API endpoint.</param> /// <param name="realm">The realm.</param> /// <param name="version">The version.</param> /// <param name="resourceName">Name of the resource.</param> /// <param name="resourceAction">The resource action.</param> /// <param name="key">The key.</param> /// <param name="queryString">The query string.</param> /// <returns></returns> protected internal virtual string GetRequestUri(ApiEndpoint apiEndpoint, string realm, string version, string resourceName, string resourceAction, string key, Dictionary <string, string> queryString = null) { var url = string.Format("{0}{1}/{2}", GetRequestEndpoint(Endpoint, realm, version), resourceName, resourceAction).TrimEnd('/') + "/"; if (!string.IsNullOrWhiteSpace(key)) { url += (key.ToUrlEncodedText() + "/"); } if (queryString.HasItem()) { url += ("?" + queryString.ToKeyValuePairString(encodeKeyValue: true)); } return(url); }
/// <summary> /// Creates the HTTP request. /// </summary> /// <param name="httpMethod">The HTTP method.</param> /// <param name="resourceName">Name of the resource.</param> /// <param name="resourceAction">The resource action.</param> /// <param name="key">The key.</param> /// <param name="queryString">The query string.</param> /// <returns>System.Net.HttpWebRequest.</returns> protected HttpWebRequest CreateHttpRequest(string httpMethod, string resourceName, string resourceAction, string key, Dictionary<string, string> queryString = null) { var url = string.Format("{0}{1}/{2}", this.BaseUrl, resourceName, resourceAction).TrimEnd('/') + "/"; if (!string.IsNullOrWhiteSpace(key)) { url += (key + "/"); } if (queryString.HasItem()) { url += ("?" + queryString.ToKeyValueStringWithUrlEncode()); } var httpRequest = url.CreateHttpWebRequest(httpMethod, acceptGZip: this.AcceptGZip); FillAdditionalData(httpRequest); return httpRequest; }
/// <summary> /// Creates the CheckBox. /// </summary> /// <param name="value">The value.</param> /// <param name="isChecked">if set to <c>true</c> [is checked].</param> /// <param name="classNames">The class names.</param> /// <param name="labelName">Name of the label.</param> /// <param name="styles">The styles.</param> /// <param name="domId">The DOM identifier.</param> /// <param name="otherAttributes">The other attributes.</param> /// <returns></returns> public static string CreateCheckBox(string value, bool isChecked, string classNames = null, string labelName = null, string styles = null, string domId = null, Dictionary <string, string> otherAttributes = null) { StringBuilder builder = new StringBuilder(256); if (string.IsNullOrWhiteSpace(labelName)) { builder.Append("<input type=\"checkbox\" "); } else { builder.Append("<label><input type=\"checkbox\" "); } if (isChecked) { builder.Append("checked=\"checked\" "); } builder.Append("value=\""); builder.Append(value.SafeToString()); builder.Append("\" "); if (!string.IsNullOrWhiteSpace(classNames)) { builder.Append("class=\""); builder.Append(classNames); builder.Append("\" "); } if (!string.IsNullOrWhiteSpace(domId)) { builder.Append("id=\""); builder.Append(domId); builder.Append("\" "); } if (!string.IsNullOrWhiteSpace(styles)) { builder.Append("style=\""); builder.Append(styles); builder.Append("\" "); } if (otherAttributes.HasItem()) { foreach (var one in otherAttributes) { builder.Append(one.Key); builder.Append("=\""); builder.Append(one.Value.SafeToString()); builder.Append("\" "); } } builder.Append("/>"); if (!string.IsNullOrWhiteSpace(labelName)) { builder.Append(labelName); builder.Append("</label>"); } return(builder.ToString()); }
/// <summary> /// Creates the HTTP request. /// </summary> /// <param name="httpMethod">The HTTP method.</param> /// <param name="resourceName">Name of the resource.</param> /// <param name="resourceAction">The resource action.</param> /// <param name="key">The key.</param> /// <param name="queryString">The query string.</param> /// <returns>System.Net.HttpWebRequest.</returns> protected HttpWebRequest CreateHttpRequest(string httpMethod, string resourceName, string resourceAction, string key, Dictionary<string, string> queryString = null) { var url = string.Format("{0}{1}/{2}", this.BaseUrl.SafeToString("htp://localhost/api/"), resourceName, resourceAction).TrimEnd('/') + "/"; if (!string.IsNullOrWhiteSpace(key)) { url += (key.ToUrlEncodedText() + "/"); } if (queryString.HasItem()) { url += ("?" + queryString.ToKeyValueStringWithUrlEncode()); } var httpRequest = url.CreateHttpWebRequest(httpMethod, acceptGZip: this.AcceptGZip, omitServerCertificateValidation: true); FillAdditionalData(httpRequest); return httpRequest; }
public ActionResult UploadLibrary() { try { Dictionary<string, byte[]> assemblyBytes = new Dictionary<string, byte[]>(); if (Request.Files != null && Request.Files.Keys != null) { var key = Request.Files.Keys[0]; foreach (HttpPostedFileBase one in Request.Files.GetMultiple(key)) { assemblyBytes.Add(string.IsNullOrWhiteSpace(one.FileName) ? string.Empty : Path.GetFileNameWithoutExtension(one.FileName), one.InputStream.ToBytes()); } } if (!assemblyBytes.HasItem()) { throw ExceptionFactory.CreateInvalidObjectException(nameof(assemblyBytes)); } var workshopKey = WorkshopManager.InitializeWorkshop(assemblyBytes); return RedirectToAction("Workshop", new { key = workshopKey }); } catch (Exception ex) { return this.HandleExceptionToRedirection(ex); } }