Example #1
0
        // GET: Track/Create
        public ActionResult Create()
        {
            var form = new TrackAddForm();

            form.AlbumList     = new SelectList(man.AlbumGetAll(), "AlbumId", "Title");
            form.MediaTypeList = new SelectList(man.MediaTypeGetAll(), "MediaTypeId", "Name");
            return(View(form));
        }
Example #2
0
        // GET: Tracks/Create
        public ActionResult Create()
        {
            System.Diagnostics.Debug.WriteLine("GET");
            var form = new TrackAddForm();

            form.AlbumList     = new SelectList(m.AlbumGetAll(), "AlbumId", "Title");
            form.MediaTypeList = new SelectList(m.MediaTypeGetAll(), "MediaTypeId", "Name");
            return(View(form));
        }
Example #3
0
 public ActionResult Create(TrackAddForm newTrack)
 {
     if (!ModelState.IsValid)
     {
         return(View(newTrack));
     }
     else
     {
         var addedItem = man.TrackAdd(newTrack);
     }
     return(RedirectToAction("Index"));
 }
Example #4
0
        public ActionResult Create(TrackAddForm newItem)
        {
            TrackBase addedItem = null;

            if (ModelState.IsValid)
            {
                addedItem = m.TrackAdd(newItem);
            }
            else
            {
                return(View(newItem));
            }

            return(RedirectToAction("Index"));
        }
Example #5
0
        public TrackBase TrackAdd(TrackAddForm newItem)
        {
            var a = ds.Albums.Find(newItem.AlbumId);
            var t = ds.MediaTypes.Find(newItem.MediaTypeId);

            if (a == null)
            {
                return(null);
            }

            else
            {
                var addedItem = ds.Tracks.Add(mapper.Map <TrackAdd, Track>(newItem));
                addedItem.Album = a;
                ds.SaveChanges();
                return((addedItem == null) ? null : mapper.Map <Track, TrackWithDetail>(addedItem));
            }
        }
Example #6
0
        public ActionResult Create(TrackAddForm newItem)
        {
            if (!ModelState.IsValid)
            {
                return(View(newItem));
                //addedItem = m.TrackAdd(newItem);
            }

            var addedItem = m.TrackAdd(newItem);

            if (addedItem == null)
            {
                return(View(newItem));
            }
            else
            {
                //return View(newItem);
                return(RedirectToAction("Details", "TrackWithDetail", new { id = addedItem.TrackId }));
            }
        }
Example #7
0
        public TrackWithDetail TrackAdd(TrackAddForm newItem)
        {
            System.Diagnostics.Debug.WriteLine("Adding a track");

            var a = ds.Albums.Find(newItem.AlbumId);
            var t = ds.MediaTypes.Find(newItem.MediaTypeId);

            System.Diagnostics.Debug.WriteLine("Media Type is " + t);



            if (a == null)
            {
                return(null);
            }

            else
            {
                var addedItem = ds.Tracks.Add(mapper.Map <Track>(newItem));
                addedItem.Album = a;
                ds.SaveChanges();
                return((addedItem == null) ? null : mapper.Map <TrackWithDetail>(addedItem));
            }
        }