private bool SaveScreenshot(CreateImageViewModel model) { var file = model.Image; if (file == null) { return false; } string fileName = Guid.NewGuid().ToString(); string path = Server.MapPath("~/Images/Screenshots/"); if (!(UploadImage(file, fileName, path, "format=jpg") && UploadImage(file, fileName, path + "Thumbs\\", "width=150&format=jpg"))) { return false; } model.ImageUrl = path + fileName + ".jpg"; model.ImageThumbUrl = path + "Thumbs\\" + fileName + ".jpg"; return true; }
public ActionResult AddToGallery(CreateImageViewModel model) { if (SaveScreenshot(model)) { var product = ProductManager.FindById(model.ProductId); var img = new GalleryImage { Product = product, ImageLocation = model.ImageUrl, ImageThumb = model.ImageThumbUrl }; product.GalleryImages.Add(img); MultimediaManager.Create(img); MultimediaManager.Save(); } return ManageImages(model.ProductId); }