public SaveResult AddPainting(Painting painting) { db.Paintings.AddObject(painting); db.SaveChanges(); return new SaveResult() { WasSuccessful = true }; }
public ActionResult Create(CreatePaintingModel model) { try { // Generate Painting Object Painting painting = new Painting() { Title = model.Title, Medium = model.Medium, Year = model.Year, OriginalSizeId = model.OriginalSizeId, ImageKey = model.ImageKey }; PaintingService.AddPainting(painting); // Save Images to Storage Provider if (model.Thumbnail != null && model.FullImage != null) { // Save Thumbnail byte[] thumbBuffer = new byte[model.Thumbnail.ContentLength]; model.Thumbnail.InputStream.Read(thumbBuffer, 0, model.Thumbnail.ContentLength); string thumbKey = Utilities.GetImageKey(model.ImageKey, Constants.Images.THUMB_KEY); SaveResult thumbResult = StorageService.SaveBytes(thumbKey, thumbBuffer, false); // Save Full byte[] fullBuffer = new byte[model.FullImage.ContentLength]; model.FullImage.InputStream.Read(fullBuffer, 0, model.FullImage.ContentLength); string fullKey = Utilities.GetImageKey(model.ImageKey, Constants.Images.FULL_KEY); SaveResult fullResult = StorageService.SaveBytes(fullKey, fullBuffer, false); } return RedirectToAction("Index"); } catch { return View(); } }
private OrderPaymentModel MapOrderPaymentModel(Order order, Painting painting) { var model = new OrderPaymentModel { PaintingId = painting.PaintingId, PaintingTitle = painting.Title, PaintingThumbnail = painting.Thumbnail, FormattedPaintingPrice = order.Total.ToString("C"), Email = order.Email, FirstName = order.FirstName, LastName = order.LastName, Address1 = order.Street, Address2 = order.Street2, City = order.City, State = order.State, PhoneNumber = order.Phone }; return model; }
private OrderConfirmationModel MapOrderConfirmationModel(Order order, Painting painting) { var model = new OrderConfirmationModel { PaintingTitle = painting.Title, PaintingPrice = order.Total.ToString("C"), OrderDescription = order.Description, OrderConfirmationCode = order.ConfirmationCode, CustomerEmail = order.Email, CustomerFirstName = order.FirstName, CustomerLastName = order.LastName, CustomerAddress1 = order.Street, CustomerAddress2 = order.Street2, CustomerCity = order.City, CustomerState = order.State, CustomerZipcode = order.ZipCode, CustomerPhoneNumber = order.Phone }; return model; }