Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }