Пример #1
0
        public ActionResult Create(TrackAdd newItem)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(newItem));
                }
                // TODO: Add insert logic here
                var addedItem = m.TrackAdd(newItem);

                if (addedItem == null)
                {
                    return(View(newItem));
                }
                else
                {
                    return(RedirectToAction("details", new { id = addedItem.Id }));
                }
            }
            catch
            {
                return(View());
            }
        }
Пример #2
0
        public TrackBase TrackAdd(TrackAdd newItem)
        {
            var addedItem = ds.Tracks.Add(mapper.Map <Track>(newItem));

            ds.SaveChanges();
            return((addedItem == null) ? null : mapper.Map <TrackBase>(addedItem));
        }
Пример #3
0
        public TrackAdd 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, TrackAdd>(addedItem));
        }
Пример #4
0
        public ActionResult AddTrack(TrackAdd newItem)
        {
            var addedItem = m.TrackAddNew(newItem);

            if (addedItem == null)
            {
                return(View(newItem));
            }
            else
            {
                return(RedirectToAction("details", "Track", new { id = addedItem.Id }));
            }
        }
Пример #5
0
        public TrackWithDetails TrackAdd(TrackAdd track)
        {
            var addedTrack = ds.Tracks.Add(mapper.Map <TrackAdd, Track>(track));


            foreach (var item in track.AlbumIds)
            {
                var a = ds.Albums.Find(item);
                addedTrack.Albums.Add(a);
            }

            ds.SaveChanges();

            return(addedTrack == null ? null : mapper.Map <Track, TrackWithDetails>(addedTrack));
        }
Пример #6
0
        public TrackWithDetail TrackAdd(TrackAdd newItem)
        {
            var a = ds.Albums.Find(newItem.AlbumIds);

            if (a == null)
            {
                return(null);
            }
            else
            {
                var addedItem = ds.Tracks.Add(mapper.Map <TrackAdd, Track>(newItem));
                addedItem.Albums.Add(a);
                ds.SaveChanges();

                return((addedItem == null) ? null : mapper.Map <Track, TrackWithDetail>(addedItem));
            }
        }
Пример #7
0
        public ActionResult Create(TrackAdd track)
        {
            if (!ModelState.IsValid)
            {
                return(View(track));
            }
            var addedTrack = m.TrackAdd(track);

            if (addedTrack != null)
            {
                return(RedirectToAction("Details", new { id = addedTrack.Id }));
            }
            else
            {
                return(View());
            }
        }
Пример #8
0
        public TrackBase TrackAdd(TrackAdd newItem, int id)
        {
            //var albumid = id;
            // variable gets id
            var addGenre = ds.Genres.Find(newItem.GenreId);

            var addAlbum = ds.Albums.Find(id);

            var addedItem = ds.Tracks.Add(Mapper.Map <TrackAdd, Track>(newItem));

            addedItem.Genre = addGenre.Name;

            addedItem.Albums.Add(addAlbum);


            ds.SaveChanges();

            return((addedItem == null) ? null : Mapper.Map <Track, TrackBase>(addedItem));
        }
Пример #9
0
        public TrackBase TrackAddNew(TrackAdd newItem)
        {
            var addedItem = ds.Tracks.Add(Mapper.Map <Track>(newItem));

            addedItem.Genre = newItem.Genre;
            addedItem.Clerk = userAccount.Name;

            // First, extract the bytes from the HttpPostedFile object
            byte[] photoBytes = new byte[newItem.AudioUpload.ContentLength];
            newItem.AudioUpload.InputStream.Read(photoBytes, 0, newItem.AudioUpload.ContentLength);

            // Then, configure the new object's properties
            addedItem.Audio            = photoBytes;
            addedItem.AudioContentType = newItem.AudioUpload.ContentType;

            ds.SaveChanges();

            return((addedItem == null) ? null : Mapper.Map <TrackBase>(addedItem));
        }
Пример #10
0
        public ActionResult AddTrack(TrackAdd newItem, int id)
        {
            newItem.Clerk = HttpContext.User.Identity.Name;

            if (!ModelState.IsValid)
            {
                return(View(newItem));
            }
            var aid       = id;
            var addedItem = m.TrackAdd(newItem, id);

            if (addedItem == null)
            {
                return(View(newItem));
            }
            else
            {
                return(RedirectToAction("../Track/details", new { id = addedItem.Id }));
            }
        }
Пример #11
0
        public ActionResult AddTrack(TrackAdd newItem)
        {
            //Validate
            if (!ModelState.IsValid)
            {
                return(View(newItem));
            }

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

            if (addedItem == null)
            {
                return(View(newItem));
            }
            else
            {
                return(RedirectToAction("details", "track", new { id = addedItem.Id }));
            }
        }
Пример #12
0
        public ActionResult Create(TrackAdd collection)
        {
            collection.Clerk = HttpContext.User.Identity.Name;
            ModelState.Clear();

            if (!ModelState.IsValid)
            {
                return(View(collection));
            }

            var addedItem = m.TrackAdd(collection);

            if (addedItem == null)
            {
                return(View(collection));
            }
            else
            {
                return(RedirectToAction("details", new { id = addedItem.Id }));
            }
        }
Пример #13
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 }));
            }
        }