public static IHtmlString ThumbnailWithMicrodata(ImageVm vm, params string[] css) { TagBuilder tag = Image(vm, isThumbnail: true, css); tag.ItemProp("image"); return(new HtmlString(tag.SafeToString(TagRenderMode.SelfClosing))); }
public static ImageVm UploadImage(UploadImageVm model) { byte[] data = Convert.FromBase64String(model.Base64Image.Substring(model.Base64Image.IndexOf(',') + 1)); ImageVm imageVm = ((model.IsCropImage ? ImageBc.CropAndSave(data, model.X, model.Y, model.Width, model.Height) : ImageBc.ResizeAndSave(data, model.X, model.Y, model.Width, model.Height))).MapToImageVm(); imageVm.Url = MSLivingChoices.Mvc.Uipc.Admin.Helpers.MslcUrlBuilder.ImageHandlerUrl(imageVm); return(imageVm); }
public static string ImageHandlerUrl(ImageVm image) { if (image == null) { return(string.Empty); } return(MslcUrlBuilder.RouteUrl("Images", new { name = image.Name })); }
internal static ImageVm MapToImageVm(this Image image) { ImageVm result = new ImageVm(); if (image != null) { result.Id = image.Id; result.Name = image.Name; result.Url = image.Url; } return(result); }
public void Initialize(IViewModel viewModel, IDataContext context) { if (_vm != null) { throw new NotSupportedException(); } _vm = (ImageVm)viewModel; var paintHandler = _vm.InitializeDx(_renderControl.Handle); _renderControl.Paint += (sender, args) => paintHandler(); }
internal static ImageVm MapToImageVm(this Image image, ImageOwner owner, string alt) { ImageVm imageVm = new ImageVm(); if (image != null) { imageVm.Src = image.Url; imageVm.ThumbnailSrc = image.ThumbnailUrl; } imageVm.Alt = alt; imageVm.Owner = owner; return(imageVm); }
private static TagBuilder Image(ImageVm vm, bool isThumbnail, params string[] css) { if (vm == null) { return(null); } string value = (isThumbnail ? vm.ThumbnailSrc : vm.Src); string arg = (isThumbnail ? vm.Src : vm.ThumbnailSrc); TagBuilder tagBuilder = new TagBuilder("img"); tagBuilder.MergeAttribute("onerror", string.Format("this.onerror=function() {{ this.onerror=null; this.src=\"{1}\"}};this.src=\"{0}\"", arg, vm.OnErrorSrc)); tagBuilder.MergeAttribute("alt", vm.Alt); tagBuilder.MergeAttribute("src", value); tagBuilder.MergeAttribute("title", vm.Alt); tagBuilder.Css(css); return(tagBuilder); }
public async Task <ActionResult> CreateImage([FromForm] ImageVm image) { var image1 = new Image(); string path = _webHostEnvironment.WebRootPath + "\\images\\"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } using (FileStream fileStream = System.IO.File.Create(path + image.ImageFile.FileName)) { image.ImageFile.CopyTo(fileStream); fileStream.Flush(); image1.ImagePath = "/images/" + image.ImageFile.FileName.ToString(); } image1.ProductId = image.ProductId; _context.Images.Add(image1); await _context.SaveChangesAsync(); return(NoContent()); }
public static IHtmlString Thumbnail(ImageVm vm, params string[] css) { return(new HtmlString(Image(vm, isThumbnail: true, css).SafeToString(TagRenderMode.SelfClosing))); }