Example #1
0
        public int SavePhoto(HttpPostedFileBase photo, int pid)
        {
            var prodImg = new ProdImage();
            WebImage formImg = null;
            byte[] imgBytes = null;
            //if (photo.ContentLength > 1000000) {
            //    formImg = new WebImage(photo.InputStream);
            //    imgBytes = formImg.Resize(formImg.Width / 2, formImg.Height / 2).GetBytes();
            //    prodImg.ImageDataType = imgBytes;
            //}
            //else
            prodImg.ImageDataType = new BinaryReader(photo.InputStream).ReadBytes(photo.ContentLength);

            prodImg.ProductID = pid;

            prodImg.ImageMimeType = photo.ContentType;
            db.ProdImages.Add(prodImg);

            db.SaveChanges();
            prodImg.Sortindex = prodImg.ID;
            db.SaveChanges();
            return prodImg.ID;
        }
Example #2
0
 public void PhotoDel(ProdImage pimg)
 {
     db.ProdImages.Remove(pimg);
     db.SaveChanges();
 }