public async Task<ActionResult> EditPhoto(int id, InstrumentEditPhoto newItem) { // Validate the requested item if (!ModelState.IsValid | id != newItem.Id) { // There was a problem, so re-display var form = new InstrumentEditPhoto(id, newItem.Description, newItem.MediaSize); ModelState.AddModelError("modelState", "There was an error. The incoming data is invalid."); return View(form); } // Attempt to do the update if (newItem.PhotoUpload != null) { await m.SetPhoto(id, newItem.PhotoUpload); } return RedirectToAction("details", new { id = id }); }
// GET: Instruments/EditPhoto/5 public async Task<ActionResult> EditPhoto(int? id) { // Validate the requested item var item = await m.GetInstrumentByIdAsync(id.GetValueOrDefault()); if (item == null) { return HttpNotFound(); } else { // Create an edit form object var description = string.Format("{0} {1} {2}", item.Item.ManufacturerName, item.Item.InstrumentName, item.Item.Category); var form = new InstrumentEditPhoto(id.Value, description, item.Item.PhotoMediaLength); return View(form); } }