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)); }
protected void TmdbLinkButton_OnClick(object Sender, EventArgs E) { string id; if (string.IsNullOrWhiteSpace(id = TmdbAssistant.ExtractTmdbID(TmdbUrlTextBox.Text))) { ErrorTmdbLink.Visible = true; ErrorTmdbLink.InnerText = Resources.ErrorUrlInvalid; } else { RegisterAsyncTask(new PageAsyncTask(async() => { await FetchTmdbDataAsync(id); })); } }
bool IsFormValid() { var isValid = true; string tmdbMovieID; if (string.IsNullOrWhiteSpace(tmdbMovieID = TmdbAssistant.ExtractTmdbID(TmdbUrlTextBox.Text))) { SetFieldError(ref isValid, ErrorTmdbLink, Resources.ErrorUrlInvalid); } if (tmdbMovieID != TmdbMovieIDHidden.Value) { SetFieldError(ref isValid, ErrorTmdbLink, Resources.ErrorTmdbLinkMismatch); } if (string.IsNullOrWhiteSpace(TitleTextBox.Text)) { SetFieldError(ref isValid, ErrorTitle, Resources.RequiredField); } if (string.IsNullOrWhiteSpace(DescriptionTextBox.Text)) { SetFieldError(ref isValid, ErrorDescription, Resources.RequiredField); } if (isValid && _moviePropsalID <= 0) { var prop = _repo.GetSingle(TmdbMovieID: tmdbMovieID); if (prop != null) { SuccessErrorReporter.ShowError = true; SuccessErrorReporter.ErrorMessage = Resources.ErrorDuplicateMovieProposal; isValid = false; } } return(isValid); }