public ActionResult Edit(int? id) { var contract = id != null ? Service.GetSongListForEdit(id.Value, false) : new SongListForEditContract(); var model = new SongListEdit(contract); return View(model); }
public ActionResult Edit(SongListEdit model) { var coverPicUpload = Request.Files["thumbPicUpload"]; UploadedFileContract uploadedPicture = null; if (coverPicUpload != null && coverPicUpload.ContentLength > 0) { CheckUploadedPicture(coverPicUpload, "thumbPicUpload"); uploadedPicture = new UploadedFileContract {Mime = coverPicUpload.ContentType, Stream = coverPicUpload.InputStream}; } if (!ModelState.IsValid) { return View(model); } var listId = queries.UpdateSongList(model.ToContract(), uploadedPicture); return RedirectToAction("Details", new { id = listId }); }