示例#1
0
        public TrackBase TrackAdd(TrackAdd newItem)
        {
            var addedItem = ds.Tracks.Add(Mapper.Map <TrackAdd, Track>(newItem));
            var findGenre = ds.Genres.Find(newItem.GenreId);

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

            return((addedItem == null) ? null : Mapper.Map <Track, TrackBase>(addedItem));
        }
示例#2
0
        public ActionResult AddTrack(TrackAdd newItem)
        {
            newItem.Clerk = HttpContext.User.Identity.Name;

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

            // Process Input
            var addedItem = m.TrackAdd(newItem);

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