Exemplo n.º 1
0
        public TrackBase TrackAdd(TrackAdd newItem)
        {
            var addedItem = ds.Tracks.Add(mapper.Map <TrackAdd, Track>(newItem));

            byte[] mediaBytes = new byte[newItem.MediaUpload.ContentLength];
            newItem.MediaUpload.InputStream.Read(mediaBytes, 0, newItem.MediaUpload.ContentLength);

            addedItem.Media            = mediaBytes;
            addedItem.MediaContentType = newItem.MediaUpload.ContentType;
            addedItem.Clerk            = User.Name;

            ds.SaveChanges();

            return((addedItem == null) ? null : mapper.Map <Track, TrackBase>(addedItem));
        }
Exemplo n.º 2
0
        public TrackBase TrackAdd(TrackAdd newItem)
        {
            // Attempt to add the new item
            var addedItem = ds.Tracks.Add(Mapper.Map <TrackAdd, Track>(newItem));
            var addGenre  = 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;
            // Set the associated item property
            addedItem.Genre = addGenre.Name;

            ds.SaveChanges();

            return((addedItem == null) ? null : Mapper.Map <Track, TrackBase>(addedItem));
        }
Exemplo n.º 3
0
        public ActionResult Create(TrackAdd newItem)
        {
            // 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("Details", new { id = addedItem.Id }));
            }
        }
Exemplo n.º 4
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 }));
            }
        }