public ActionResult Create([Bind(Include = "SerialId,Make,Model,PriceExBtw,BtwPercentage,CreationDate,TracklistId,MbSize,DisplayWidth,DisplayHeight")] VMMp3Player vMMp3Player)
        {
            if (ModelState.IsValid)
            {
                var device = new AudioDevices.AudioDevice()
                {
                    Make          = vMMp3Player.Make,
                    Model         = vMMp3Player.Model,
                    CreationDate  = vMMp3Player.CreationDate,
                    PriceExBtw    = vMMp3Player.PriceExBtw,
                    BtwPrecentage = (decimal)vMMp3Player.BtwPercentage,
                    SerialId      = vMMp3Player.SerialId
                };

                var recorder = new Mp3Player()
                {
                    MbSize        = vMMp3Player.MbSize,
                    DisplayWidth  = vMMp3Player.DisplayWidth,
                    DisplayHeight = vMMp3Player.DisplayHeight,
                    TrackList     = vMMp3Player.TrackListId,
                    AudioDevice   = device
                };
                db.AudioDevice.Add(device);
                db.Mp3Player.Add(recorder);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.TracklistId = new SelectList(db.TrackList, "ID", "Name", vMMp3Player.TrackListId);
            return(View(vMMp3Player));
        }
        // GET: Mp3Player
        public ActionResult Index()
        {
            var tracklistname = db.TrackList.Include(t => t.Name);
            var mp3players    = new List <VMMp3Player>();

            foreach (var mr in db.Mp3Player)
            {
                // Create a new viewmodel

                var recorder = new VMMp3Player()
                {
                    Make           = mr.AudioDevice.Make,
                    Model          = mr.AudioDevice.Model,
                    CreationDate   = mr.AudioDevice.CreationDate,
                    PriceExBtw     = mr.AudioDevice.PriceExBtw,
                    BtwPercentage  = (double)mr.AudioDevice.BtwPrecentage,
                    SerialId       = mr.AudioDevice.SerialId,
                    MbSize         = mr.MbSize,
                    DisplayWidth   = mr.DisplayWidth,
                    DisplayHeight  = mr.DisplayHeight,
                    TrackListId    = mr.TrackList,
                    TracklistNames = mr.TrackList1,
                };
                mp3players.Add(recorder);
            }
            // Add the viewmodel to the list
            return(View(mp3players));
        }
        // GET: Mp3Player/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var recorder = db.Mp3Player.Find(id);

            if (recorder == null)
            {
                return(HttpNotFound());
            }
            var mr = new VMMp3Player()
            {
                Make           = recorder.AudioDevice.Make,
                Model          = recorder.AudioDevice.Model,
                CreationDate   = recorder.AudioDevice.CreationDate,
                PriceExBtw     = recorder.AudioDevice.PriceExBtw,
                BtwPercentage  = (double)recorder.AudioDevice.BtwPrecentage,
                SerialId       = recorder.AudioDevice.SerialId,
                MbSize         = recorder.MbSize,
                DisplayWidth   = recorder.DisplayWidth,
                DisplayHeight  = recorder.DisplayHeight,
                TrackListId    = recorder.TrackList,
                TracklistNames = recorder.TrackList1,
            };

            return(View(mr));
        }
        public ActionResult Edit([Bind(Include = "SerialId,Make,Model,PriceExBtw,BtwPercentage,CreationDate,TrackListId,MbSize,DisplayWidth,DisplayHeight")] VMMp3Player vMMp3Player)
        {
            if (ModelState.IsValid)
            {
                var device = db.AudioDevice.Find(vMMp3Player.SerialId);
                device.Make          = vMMp3Player.Make;
                device.Model         = vMMp3Player.Model;
                device.CreationDate  = vMMp3Player.CreationDate;
                device.PriceExBtw    = vMMp3Player.PriceExBtw;
                device.BtwPrecentage = (decimal)vMMp3Player.BtwPercentage;
                device.SerialId      = vMMp3Player.SerialId;

                var recorder = db.Mp3Player.Find(vMMp3Player.SerialId);
                recorder.MbSize        = vMMp3Player.MbSize;
                recorder.DisplayWidth  = vMMp3Player.DisplayWidth;
                recorder.DisplayHeight = vMMp3Player.DisplayHeight;
                recorder.TrackList     = vMMp3Player.TrackListId;
                recorder.AudioDevice   = device;

                db.Entry(device).State   = EntityState.Modified;
                db.Entry(recorder).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.TracklistId = new SelectList(db.TrackList, "ID", "Name", vMMp3Player.TrackListId);
            return(View(vMMp3Player));
        }
        // GET: Mp3Player
        public ActionResult Index()
        {
            List <VMMp3Player> mp3Players = new List <VMMp3Player>();

            foreach (var item in mp3Player)
            {
                VMMp3Player Mp3p = new VMMp3Player();
                Mp3p.DisplayHeight = item.DisplayHeight;
                Mp3p.DisplayWidth  = item.DisplayWidth;
                Mp3p.MbSize        = item.MbSize;
                Mp3p.Picture       = item.Picture;
                Mp3p.TotalPixels   = item.TotalPixels;
                mp3Players.Add(Mp3p);
            }
            return(View(mp3Players));
        }