public ActionResult CreateSong(int HdnRelID, Song song, HttpPostedFileBase UploadedFile) { Release rel = Uow.ReleaseRepository.GetByID(HdnRelID); if (ModelState.IsValid && rel != null) { if (UploadedFile != null) song.FilePath = Server.MapPath("/Files/Releases/").SaveFile(UploadedFile); song.Date_Creation = DateTime.Now; Uow.SongRepository.Add(song); rel.Songs.Add(song); Uow.Commit(); return RedirectToAction("Edit", new { id = HdnRelID }); } ViewBag.RelId = HdnRelID; ViewBag.Genres = Uow.ReleaseRepository.GetAllGenres().ToList(); return View(song); }
public ActionResult EditSong(int HdnRelID, Song song, HttpPostedFileBase UploadedFile) { if (ModelState.IsValid) { Song Entity = Uow.SongRepository.GetByID(song.ID); UpdateModel(Entity); if (UploadedFile != null) Entity.FilePath = Server.MapPath("/Files/Releases/").SaveFile(UploadedFile); Uow.Commit(); return RedirectToAction("Edit", new { id = HdnRelID }); } ViewBag.RelId = HdnRelID; return View(song); }