public static MvcHtmlString ImageDataForCart(this HtmlHelper helper, int clothesId,string clothesName) { TagBuilder imageData = null; //To Build the Image Tag var imgUrl = new UrlHelper(helper.ViewContext.RequestContext); UCEntities uCEntities = new UCEntities(); int? imageId = uCEntities.Pictures.FirstOrDefault(x => x.ClothesId == clothesId).PictureId; // if (imageId!=0) //{ byte[] imageArray = uCEntities.Pictures.Where(x => x.PictureId == imageId).FirstOrDefault().Image; //Convert to Image TypeConverter bmpConverter = TypeDescriptor.GetConverter(typeof(Bitmap)); Bitmap imageReceived = (Bitmap)bmpConverter.ConvertFrom(imageArray); //Now Generate the Image Tag for Mvc Html String imageReceived.Save(HostingEnvironment.MapPath("~/Images") + @"\I" + imageId.ToString() + ".jpg"); //} imageData = new TagBuilder("img"); //Set the Image Url for <img> tag as <img src=""> imageData.MergeAttribute("src", imgUrl.Content("~/Images") + @"/I" + imageId.ToString() + ".jpg"); imageData.Attributes.Add("alt", clothesName); //imageData.Attributes.Add("style", "opacity:1;"); return MvcHtmlString.Create(imageData.ToString(TagRenderMode.SelfClosing)); }
public ClothesController(UCEntities entities) { uCEntities = entities; }
public HomeController(UCEntities entities) { uCEntities = entities; }
public CheckoutController(UCEntities entities ) { storeDB = entities; }