public string AddCustomImage([FromBody] AllowedValue cid) { if (cid == null || string.IsNullOrEmpty(cid.key) || string.IsNullOrEmpty(cid.value) || string.IsNullOrEmpty(cid.url)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } return(ImagesBlob.SaveCustomImage(cid)); }
public string TypeToString(object val) { if (typeof(u) == typeof(DateTime)) { return((System.Convert.ToDateTime(AllowedValue)).JavaScriptDate()); } else if (val is bool) { return(AllowedValue.ToString().ToLower()); } else if (val is string) { return(System.Convert.ToString(AllowedValue)); } else if (val is decimal && System.Convert.ToDecimal(val) != 0) { string tempVal = val.ToString(); string leftVal = tempVal.BeforeX(".", false); if (leftVal.IsNotNullOrBlank()) { string rightVal = tempVal.AfterX(".", false); int numberDecimals; if (leftVal.StartsWith("-")) { numberDecimals = 17 - leftVal.Length; } else { numberDecimals = 16 - leftVal.Length; } if (numberDecimals > 0) { return(leftVal + "." + rightVal.Left(numberDecimals)); } else { return(leftVal + "." + rightVal); } } else { return(tempVal); } } else { return(val.ToString()); } }
public static string SaveCustomImage(AllowedValue cid) { var dataUri = cid.url; var match = rxDataUri.Match(dataUri); if (!match.Success) { throw new Exception("Invalid data URI"); } var mime = match.Groups["mime"].Value; var ext = match.Groups["ext"].Value; var bytes = Convert.FromBase64String(dataUri.Substring(match.Length)); var blob = GetBlobContainer().GetBlockBlobReference($"{cid.key}.{ext}"); blob.Properties.ContentType = mime; blob.UploadFromByteArray(bytes, 0, bytes.Length); blob.Metadata["name"] = cid.value; blob.SetMetadata(); return(blob.Uri.AbsoluteUri); }
public SetConstructorArgumentPrimitivesAspect(int value, AllowedValue allowedValue) { Value = value; AllowedValue = allowedValue; }
public SetConstructorArgumentPrimitivesAspect(int value, AllowedValue allowedValue) { Value = value; AllowedValue = allowedValue; }