Пример #1
0
        public ActionResult CreateSeason(SeasonModel model)
        {
            if (ModelState.IsValid)
            {
                Show showObj = Service.GetShowByName(model.ShowName);
                if (showObj == null)
                {
                    ModelState.AddModelError("ShowName", "Show does not exist");
                    return(View(model));
                }
                Season season = Service.GetSeason(showObj.Name, model.Number);
                if (season == null)
                {
                    season = new Season {
                        Name = model.Name, Number = model.Number, Debut = model.Debut, Finale = model.Finale
                    };
                    Service.AddSeasonToShow(showObj.Name, season);
                    return(RedirectToAction("Index"));
                }
            }

            return(View(model));
        }
Пример #2
0
        public ActionResult Create(EpisodeModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Season season = Service.GetSeason(model.ShowName, model.SeasonNumber);
                    if (season == null)
                    {
                        ModelState.AddModelError("ShowName", "Show or Season does not exist");
                        return(View(model));
                    }
                    Service.AddEpisodeToSeason(model.ShowName, model.SeasonNumber, model.ToEpisodeDomainEntity());
                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                // TODO: LOG
                return(new HttpStatusCodeResult(( int )HttpStatusCode.InternalServerError));
            }

            return(View(model));
        }
Пример #3
0
 public ShowsView(Show show)
     : base("Show",
            A(ResolveUri.ForNewProposalFromExistingShow(show), "Create a Proposal")
            , Ul(Li(Text("Name: "), Text(show.Name)),
                 Li(Text("Description: "), Text(show.Description)),
                 Li(Text("Seasons: "), Ul(show.Seasons.Select(season => Li(A(ResolveUri.ForSeason(show, ShowService.GetSeason(show.Name, season.Number)), season.Name))).ToArray())))
            )
 {
 }
Пример #4
0
 public SeasonView(string show, Season season) :
     base("Season",
          A(ResolveUri.ForHome(), "Home")
          , H1(Text("TV Shows"))
          , H2(Text(show))
          , H3(Text(string.Format("Starts: {0}", season.Debut.ToString("d"))))
          , H3(Text(string.Format("Ends: {0}", season.Finale.ToString("d"))))
          , Ul(season.Episodes.Select(episode => Li(A(
                                                        ResolveUri.ForEpisode(ShowService.GetShowByName(show)
                                                                              , ShowService.GetSeason(show, season.Number)
                                                                              , ShowService.GetEpisodeByNumberShowAndSeason(show, season.Number, episode.Number)
                                                                              )
                                                        , episode.Title)
                                                    )
                                      ).ToArray()
               )
          )
 {
 }