Example #1
0
        public ActionResult NewMedia()
        {
            var model = new MediaViewModel();
            var mediaTypes = m_repo.GetMediaTypes().ToList();
            var mediaGenres = m_repo.GetMediaGenres().ToList();

            model.MediaTypes = new List<SelectListItem>();
            foreach (var m in mediaTypes)
            {
                model.MediaTypes.Add(new SelectListItem { Value = m.Id.ToString(), Text = m.Type });
            }

            model.MediaGenres = new List<SelectListItem>();
            foreach (var m in mediaGenres)
            {
                model.MediaGenres.Add(new SelectListItem { Value = m.Id.ToString(), Text = m.Genre });
            }
            return View(model);
        }
Example #2
0
        public ActionResult NewMedia(MediaViewModel model)
        {
            if (ModelState.IsValid)
            {

                var newMedia = new Media()
                {
                    Name = model.Name,
                    DateAired = model.DateAired,
                    GenreId = model.GenreId,
                    ImdbUrl = model.ImdbUrl,
                    PosterUrl = model.PosterUrl,
                    TypeId = model.TypeId,
                    DownloadCount = 0
                };
                m_repo.AddMedia(newMedia);
                return RedirectToAction("Media", new { id = newMedia.Id });
            }
            return View(model);
        }
Example #3
0
 public ActionResult Media(int? id)
 {
     if (id.HasValue)
     {
         var media = (from m in m_repo.GetMedias()
                      where m.Id == id.Value
                      select m).SingleOrDefault();
         var languages = m_repo.GetSubtitleLanguages();
         MediaViewModel model = new MediaViewModel {
             DateAired = media.DateAired,
             Id = media.Id,
             Genre = media.Genre,
             ImdbUrl = media.ImdbUrl,
             Name = media.Name,
             PosterUrl = media.PosterUrl,
             Type = media.Type,
             SelectedLanguage = "languageId",
             SubtitleLanguages = new List<SelectListItem>()};
         foreach (var l in languages)
         {
             model.SubtitleLanguages.Add(new SelectListItem { Value = l.Id.ToString(), Text = l.Language });
         }
         return View(model);
     }
     return View("Error");
 }