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

            byte[] audioBytes = new byte[newItem.AudioUpload.ContentLength];
            newItem.AudioUpload.InputStream.Read(audioBytes, 0, newItem.AudioUpload.ContentLength);

            addedItem.Audio            = audioBytes;
            addedItem.AudioContentType = newItem.AudioUpload.ContentType;
            addedItem.Genre            = findGenre.Name;

            ds.SaveChanges();

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

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

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

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