Esempio n. 1
0
        public AlbumBase AlbumAdd(AlbumAdd newItem)
        {
            // Attempt to add the new item
            var addedItem = ds.Albums.Add(Mapper.Map <AlbumAdd, Album>(newItem));
            var findGenre = ds.Genres.Find(newItem.GenreId);

            addedItem.Genre = findGenre.Name;
            ds.SaveChanges();

            return((addedItem == null) ? null : Mapper.Map <Album, AlbumBase>(addedItem));
        }
Esempio n. 2
0
        public ActionResult AddAlbum(AlbumAdd newItem)
        {
            newItem.Coordinator = HttpContext.User.Identity.Name;

            // Validate the input
            if (!ModelState.IsValid)
            {
                return(View(newItem));
            }

            // Process the input
            var addedItem = m.AlbumAdd(newItem);

            if (addedItem == null)
            {
                return(View(newItem));
            }
            else
            {
                return(RedirectToAction("../album/details", new { id = addedItem.Id }));
            }
        }