public async Task<ActionResult> EditSoundClip(int id, InstrumentEditSoundClip newItem) { // Validate the requested item if (!ModelState.IsValid | id != newItem.Id) { // There was a problem, so re-display var form = new InstrumentEditSoundClip(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.SoundClipUpload != null) { await m.SetSoundClip(id, newItem.SoundClipUpload); } return RedirectToAction("details", new { id = id }); }
// GET: Instruments/EditSoundClip/5 public async Task<ActionResult> EditSoundClip(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 InstrumentEditSoundClip(id.Value, description, item.Item.SoundClipMediaLength); return View(form); } }