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));
        }
Beispiel #2
0
        protected void SaveButton_OnClick(object Sender, EventArgs E)
        {
            if (IsFormValid())
            {
                var xml = MovieProposal.BuildXmlForTX(Master.UserObject.ID,
                                                      CountryDropDown.Value,
                                                      TitleTextBox.Text,
                                                      SlugHidden.Value,
                                                      DescriptionTextBox.Text,
                                                      TmdbUrlTextBox.Text,
                                                      TmdbMovieIDHidden.Value,
                                                      ReleaseYearInput.Value,
                                                      PosterUrlTextBox.Text,
                                                      TrailerUrlTextBox.Text,
                                                      IsPublishedCheckBox.Checked,
                                                      RuntimeMinutesInput.Value,
                                                      GenresDropDown.Items
                                                      .Cast <ListItem>()
                                                      .Where(x => x.Selected)
                                                      .Select(x => x.Value)
                                                      );

                _repo.TX(0, xml);

                if (!_repo.IsError && _repo.ID > 0)
                {
                    Session.SetIsSuccess(true);
                    Session.SetMessage(Resources.OperationSuccessful);
                    Response.Redirect("~/administration/cm/MovieProposalDetails.aspx?ID=" + _repo.ID);
                }
                else
                {
                    Session.SetIsSuccess(false);
                    Session.SetMessage(Resources.ErrorGeneral);
                    Response.Redirect(Request.Url.OriginalString);
                }
            }
        }