예제 #1
0
        public void Save(Album album)
        {
            if (album.Id > 0)
            {
                _db.Album.Attach(album);
                _db.Entry(album).State = EntityState.Modified;
                _db.SaveChanges();
                return;
            }

            _db.Album.Add(album);
            _db.SaveChanges();
        }
예제 #2
0
        public ActionResult Add(Album album)
        {
            if (!ModelState.IsValid)
            {
                return View(album);
            }

            album.Name = album.Name.Replace(".", string.Empty);

            var coverPath = SaveAttach("cover", Request.Files["Cover"]);
            var bgForAlbumPath = SaveAttach("cover", Request.Files["BgForAlbum"]);
            if (!string.IsNullOrEmpty(coverPath))
                album.CoverFileName = coverPath;
            if (!string.IsNullOrEmpty(bgForAlbumPath))
                album.BackgroundFileName = bgForAlbumPath;

            if (album.Id <= 0)
            {
                var order = AlbumRepository.Count() + 1;
                album.Order = order;
            }

            AlbumRepository.Save(album);

            Directory.CreateDirectory(Path.Combine(Server.MapPath("~/Content/song/"), album.Name));

            return RedirectToAction("Albums");
        }
예제 #3
0
 // -------------------- Album Region --------------------
 public ActionResult Add()
 {
     var model = new Album();
     return View(model);
 }