示例#1
0
        public async Task <ActionResult> CreateProposal(string TmdbUrl)
        {
            var success     = false;
            var message     = Resources.ErrorGeneral;
            var redirectUrl = "";

            var tmdbMovieID = TmdbAssistant.ExtractTmdbID(TmdbUrl);

            if (!string.IsNullOrWhiteSpace(tmdbMovieID))
            {
                var proposal = MovieProposalRepo.GetSingle(TmdbMovieID: tmdbMovieID);
                if (proposal == null)
                {
                    var tmdbMovie = await TmdbAssistant.GetMovieAsync(tmdbMovieID);

                    if (tmdbMovie != null)
                    {
                        var xml = MovieProposal.BuildXmlForTX(CurrentUser.ID,
                                                              tmdbMovie.PremiereCountryIso,
                                                              tmdbMovie.Title,
                                                              tmdbMovie.Title.Replace(" ", "-"),
                                                              tmdbMovie.Overview,
                                                              "https://www.themoviedb.org/movie/" + tmdbMovieID,
                                                              tmdbMovieID,
                                                              tmdbMovie.ReleaseYear,
                                                              tmdbMovie.PosterUrl,
                                                              "http://youtu.be/" + tmdbMovie.YoutubeTrailer,
                                                              false,
                                                              tmdbMovie.RuntimeMinutes,
                                                              tmdbMovie.GenreCodes);

                        MovieProposalRepo.TX(0, xml);

                        if (!MovieProposalRepo.IsError && MovieProposalRepo.ID > 0)
                        {
                            success     = true;
                            message     = Resources.SuccessCreateMovieProposal;
                            redirectUrl = Url.Action("Proposal", "Movies", new { MovieProposalRepo.ID });
                        }
                    }
                    else
                    {
                        message = Resources.ErrorUrlInvalid;
                    }
                }
                else
                {
                    message = Resources.ErrorDuplicateMovieProposal +
                              string.Format(" <a href=\"{0}\" target=\"_blank\">{1}</a>", Url.Action("Proposal", new { proposal.ID }), proposal.Title);
                }
            }
            else
            {
                message = Resources.ErrorUrlInvalid;
            }

            return(Json(new { Success = success, Message = message, RedirectUrl = redirectUrl }, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        async Task FetchTmdbDataAsync(string TmdbMovieID)
        {
            var movie = await TmdbAssistant.GetMovieAsync(TmdbMovieID);

            if (movie != null)
            {
                TitleTextBox.Text         = movie.Title;
                DescriptionTextBox.Text   = movie.Overview;
                PosterUrlTextBox.Text     = PosterDisplay.ImageUrl = movie.PosterUrl;
                PosterDisplay.Visible     = true;
                TmdbMovieIDHidden.Value   = TmdbMovieID;
                ReleaseYearInput.Value    = movie.ReleaseYear;
                SlugHidden.Value          = movie.Title.Replace(" ", "-");
                RuntimeMinutesInput.Value = movie.RuntimeMinutes;

                GenresDropDown.Items.Cast <ListItem>().ForEach(i => i.Selected = movie.GenreCodes.Contains(i.Value));

                var countryItem = CountryDropDown.Items
                                  .Cast <ListEditItem>()
                                  .FirstOrDefault(i => i.Value as string == movie.PremiereCountryIso);
                if (countryItem != null)
                {
                    countryItem.Selected = true;
                }
                else
                {
                    CountryDropDown.SelectedIndex = -1;
                }

                if (!string.IsNullOrWhiteSpace(movie.YoutubeTrailer))
                {
                    TrailerUrlTextBox.Text = string.Concat("http://youtu.be/", movie.YoutubeTrailer);
                    TrailerFrame.Visible   = true;
                    TrailerFrame.Src       = string.Format("//www.youtube.com/embed/{0}", movie.YoutubeTrailer);
                }
            }
            else
            {
                ErrorTmdbLink.Visible   = true;
                ErrorTmdbLink.InnerText = Resources.ErrorMovieNotFound;
            }
        }