コード例 #1
0
ファイル: ImageHelper.cs プロジェクト: donor/Projects
        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));
        }
コード例 #2
0
ファイル: ClothesController.cs プロジェクト: donor/Projects
 public ClothesController(UCEntities entities)
 {
     uCEntities = entities;
 }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: donor/Projects
 public HomeController(UCEntities entities)
 {
     uCEntities = entities;
 }
コード例 #4
0
ファイル: CheckoutController.cs プロジェクト: donor/Projects
 public CheckoutController(UCEntities entities  )
 {
     storeDB = entities;
 }