//GetAuctionImagePath public static string GetAuctionImagePath(long auction_id) { return(CheckAndCreateDirectiory(HttpContext.Current.Server.MapPath(AppHelper.AuctionImageFolder(auction_id)))); }
//UploadImage public JsonExecuteResult UploadImage(Auction auc, string file) { try { if (auc == null) { throw new NullReferenceException("Lot can't be null"); } string path = HttpContext.Current.Server.MapPath(CheckAndCreateDirectiory(AppHelper.AuctionImageFolder(auc.ID))); System.Drawing.Image img, imgNew, imgThumb; img = System.Drawing.Image.FromFile(file); string prefix = auc.ID.ToString(CultureInfo.InvariantCulture) + "-" + (auc.Images == null ? 0 : auc.Images.Count + 1).ToString(CultureInfo.InvariantCulture) + "_" + DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture); prefix += Path.GetExtension(file); imgNew = ChangeImageSize(img, Consts.AuctionImageSize, false); imgThumb = ChangeImageSize(img, Consts.AuctionImageThumbnailSize, false); imgNew.Save(Path.Combine(path, prefix), System.Drawing.Imaging.ImageFormat.Jpeg); imgThumb.Save(Path.Combine(path, "thmb_" + prefix), System.Drawing.Imaging.ImageFormat.Jpeg); img.Dispose(); imgNew.Dispose(); imgThumb.Dispose(); Image imgnew = AddAuctionImage(auc.ID, prefix, Path.GetFileName(file)); if (imgnew != null) { if (auc.Images == null) { auc.Images = new EntitySet <Image>(); } auc.Images.Add(imgnew); SubmitChanges(); } } catch (System.Runtime.InteropServices.ExternalException ex) { throw new System.Runtime.InteropServices.ExternalException(ex.Message); } catch (Exception ex) { return(new JsonExecuteResult(JsonExecuteResultTypes.ERROR, ex.Message)); } return(new JsonExecuteResult(JsonExecuteResultTypes.SUCCESS)); }