public void Remove(object sender, EventArgs e) { IUnityContainer container = (IUnityContainer)HttpContext.Current.Application["unityContainer"]; ICommentService commentService = container.Resolve <ICommentService>(); UserSession userSession = (UserSession)this.Context.Session["userSession"]; long userId = userSession.UserProfileId; try { commentService.RemoveComment(userId, CommentId); } catch (UserNotAuthorizedException <CommentDetails> ) { pError.Visible = true; } if (CookiesManager.GetPreferredSearchEngine(Context) == "webshop") { Response.Redirect(Response.ApplyAppPathModifier("~/Pages/Movie/Movie.aspx?movieId=" + MovieId)); } else { Response.Redirect(Response.ApplyAppPathModifier("~/Pages/Movie/MovieXml.aspx?movieId=" + MovieId)); } }
protected void Page_Load(object sender, EventArgs e) { CommentId = Int64.Parse(Request.Params.Get("commentId")); IUnityContainer container = (IUnityContainer)HttpContext.Current.Application["unityContainer"]; ICommentService commentService = container.Resolve <ICommentService>(); ILinkService linkService = container.Resolve <ILinkService>(); CommentDetails comment = commentService.GetComment(CommentId); LinkId = comment.LinkId; LinkDetails link = linkService.GetLink(LinkId); lnkLink.NavigateUrl = Response.ApplyAppPathModifier("/Pages/Link/Link.aspx?linkId=" + LinkId); if (!IsPostBack) { txtText.Text = comment.Text; lblLink.Text = link.Name; lblMovie.Text = ApplicationManager.GetMovieTitle(link.MovieId); if (CookiesManager.GetPreferredSearchEngine(Context) == "webshop") { lnkMovie.NavigateUrl = Response.ApplyAppPathModifier("/Pages/Movie/Movie.aspx?movieId=" + link.MovieId); } else { lnkMovie.NavigateUrl = Response.ApplyAppPathModifier("/Pages/Movie/MovieXml.aspx?movieId=" + link.MovieId); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { String preferredSearchEngine = CookiesManager.GetPreferredSearchEngine(Context); if (preferredSearchEngine != null) { ddlSearchEngine.SelectedValue = preferredSearchEngine; } } }
protected void Page_Load(object sender, EventArgs e) { string orderedBy = Request.Params.Get("orderedBy"); string userIdString = Request.Params.Get("userId"); string movieIdString = Request.Params.Get("movieId"); string labelString = Request.Params.Get("label"); string reportedString = Request.Params.Get("reported"); Type linkServiceType = typeof(ILinkService); if ((userIdString == null) && (movieIdString == null) && (labelString == null) && (reportedString != null) && (reportedString.ToLower() == "true")) { UserSession userSession = (UserSession)this.Context.Session["userSession"]; long userId = userSession.UserProfileId; IUnityContainer container = (IUnityContainer)HttpContext.Current.Application["unityContainer"]; IUserService userService = container.Resolve <IUserService>(); if (!IsPostBack) { lclLinks.Text = (string)GetLocalResourceObject("lclReportedLinks.Text"); lclFor.Visible = true; lclFor.Text += " " + (string)GetLocalResourceObject("lblUser.Text"); lnkForWhat.Visible = true; lblForWhat.Text = userService.GetUserProfile(userId).LoginName; imgForWhat.ImageUrl = (string)GetLocalResourceObject("imgReported.ImageUrl"); imgForWhat.AlternateText = (string)GetLocalResourceObject("imgReported.AlternateText"); lnkForWhat.NavigateUrl = Response.ApplyAppPathModifier("/Pages/Link/ListLinks.aspx?userId=" + userId.ToString()); } lvListLinksDataSource.SelectMethod = linkServiceType.GetMethod("GetReportedLinksForUser").Name; lvListLinksDataSource.SelectCountMethod = linkServiceType.GetMethod("CountReportedLinksForUser").Name; lvListLinksDataSource.SelectParameters.Add("userId", DbType.Int64, userId.ToString()); lvListLinksDataSource.SelectParameters.Add("threshold", DbType.Int32, Settings.Default.WebMovies_demotedThreshold.ToString()); lnkOrderBy.Visible = false; } else if (((userIdString != null) && (movieIdString == null) && (labelString == null) && (reportedString == null)) || ((userIdString == null) && (movieIdString == null) && (labelString == null) && (reportedString == null))) { if (userIdString == null) { UserSession userSession = (UserSession)this.Context.Session["userSession"]; userIdString = userSession.UserProfileId.ToString(); } long userId = Int64.Parse(userIdString); IUnityContainer container = (IUnityContainer)HttpContext.Current.Application["unityContainer"]; IUserService userService = container.Resolve <IUserService>(); if (!IsPostBack) { lclFor.Visible = true; lclFor.Text += " " + (string)GetLocalResourceObject("lblUser.Text"); lnkForWhat.Visible = true; lblForWhat.Text = userService.GetUserProfile(userId).LoginName; imgForWhat.ImageUrl = (string)GetLocalResourceObject("imgUser.ImageUrl"); imgForWhat.AlternateText = (string)GetLocalResourceObject("imgUser.AlternateText"); lnkForWhat.NavigateUrl = Response.ApplyAppPathModifier("/Pages/Link/ListLinks.aspx?userId=" + userIdString); } if (orderedBy == "rating") { lvListLinksDataSource.SelectMethod = linkServiceType.GetMethod("GetMostValuedLinksForUser").Name; } else { lvListLinksDataSource.SelectMethod = linkServiceType.GetMethod("GetLinksForUser").Name; } lvListLinksDataSource.SelectCountMethod = linkServiceType.GetMethod("CountLinksForUser").Name; lvListLinksDataSource.SelectParameters.Add("userId", DbType.Int64, userIdString); } else if ((userIdString == null) && (movieIdString != null) && (labelString == null) && (reportedString == null)) { long movieId = Int64.Parse(movieIdString); if (!IsPostBack) { lclFor.Visible = true; lclFor.Text += " " + (string)GetLocalResourceObject("lblMovie.Text"); lnkForWhat.Visible = true; lblForWhat.Text = "\"" + ApplicationManager.GetMovieTitle(movieId) + "\""; imgForWhat.ImageUrl = (string)GetLocalResourceObject("imgMovie.ImageUrl"); imgForWhat.AlternateText = (string)GetLocalResourceObject("imgMovie.AlternateText"); if (CookiesManager.GetPreferredSearchEngine(Context) == "webshop") { lnkForWhat.NavigateUrl = Response.ApplyAppPathModifier("/Pages/Movie/Movie.aspx?movieId=" + movieIdString); } else { lnkForWhat.NavigateUrl = Response.ApplyAppPathModifier("/Pages/Movie/MovieXml.aspx?movieId=" + movieIdString); } } if (orderedBy == "rating") { lvListLinksDataSource.SelectMethod = linkServiceType.GetMethod("GetMostValuedLinksForMovie").Name; } else { lvListLinksDataSource.SelectMethod = linkServiceType.GetMethod("GetLinksForMovie").Name; } lvListLinksDataSource.SelectCountMethod = linkServiceType.GetMethod("CountLinksForMovie").Name; lvListLinksDataSource.SelectParameters.Add("movieId", DbType.Int64, movieIdString); lnkAddLink.NavigateUrl = Response.ApplyAppPathModifier("~/Pages/Link/AddLink.aspx?movieId=" + movieIdString); lnkAddLink.Visible = true; } else if ((userIdString == null) && (movieIdString == null) && (labelString != null) && (reportedString == null)) { if (!IsPostBack) { lclFor.Visible = true; lclFor.Text += " " + (string)GetLocalResourceObject("lblLabel.Text"); lnkForWhat.Visible = true; lblForWhat.Text = "'" + labelString + "'"; imgForWhat.ImageUrl = (string)GetLocalResourceObject("imgLabel.ImageUrl"); imgForWhat.AlternateText = (string)GetLocalResourceObject("imgLabel.AlternateText"); lnkForWhat.NavigateUrl = Response.ApplyAppPathModifier("/Pages/Link/ListLinks.aspx?label=" + labelString); } if (orderedBy == "rating") { lvListLinksDataSource.SelectMethod = linkServiceType.GetMethod("GetMostValuedLinksForLabel").Name; } else { lvListLinksDataSource.SelectMethod = linkServiceType.GetMethod("GetLinksForLabel").Name; } lvListLinksDataSource.SelectCountMethod = linkServiceType.GetMethod("CountLinksForLabel").Name; lvListLinksDataSource.SelectParameters.Add("label", DbType.String, labelString); } else { throw new ArgumentException("Wrong URL parameters"); } lvListLinksDataSource.ObjectCreating += this.LvListLinksDataSource_ObjectCreating; lvListLinksDataSource.TypeName = linkServiceType.FullName; lvListLinksDataSource.EnablePaging = true; lvListLinksDataSource.StartRowIndexParameterName = "startIndex"; lvListLinksDataSource.MaximumRowsParameterName = "count"; dpListLinks.PageSize = Settings.Default.WebMovies_linksPerPage; lvListLinks.DataSource = lvListLinksDataSource; lvListLinks.DataBind(); if (!IsPostBack) { string reorderUrl = Request.Url.AbsolutePath + "?"; if (userIdString != null) { reorderUrl += "userId=" + userIdString; } if (movieIdString != null) { reorderUrl += "movieId=" + movieIdString; } if (labelString != null) { reorderUrl += "label=" + labelString; } if (orderedBy == "rating") { reorderUrl += "&orderedBy=date"; imgByWhat.ImageUrl = (string)GetLocalResourceObject("imgByDate.ImageUrl"); imgByWhat.AlternateText = (string)GetLocalResourceObject("imgByDate.AlternateText"); } else { reorderUrl += "&orderedBy=rating"; imgByWhat.ImageUrl = (string)GetLocalResourceObject("imgByRating.ImageUrl"); imgByWhat.AlternateText = (string)GetLocalResourceObject("imgByRating.AlternateText"); } lnkOrderBy.NavigateUrl = reorderUrl; HyperLink lnkReturn = lvListLinks.Controls[0].FindControl("lnkReturn") as HyperLink; if (lnkReturn != null) { if (Request.UrlReferrer != null) { lnkReturn.NavigateUrl = Response.ApplyAppPathModifier(Request.UrlReferrer.AbsoluteUri); } } } }
protected void Page_Load(object sender, EventArgs e) { LinkId = Int64.Parse(Request.Params.Get("linkId")); if (!IsPostBack) { IUnityContainer container = (IUnityContainer)HttpContext.Current.Application["unityContainer"]; ILinkService linkService = container.Resolve <ILinkService>(); IRatingService ratingService = container.Resolve <IRatingService>(); IFavoriteService favoriteService = container.Resolve <IFavoriteService>(); LinkDetails link = linkService.GetLink(LinkId); string searchEngine = CookiesManager.GetPreferredSearchEngine(Context); lblName.Text = link.Name; lblUrl.Text = link.Url; lnkUrl.NavigateUrl = "http://" + link.Url; lblAuthor.Text = link.UserName; lnkAuthor.NavigateUrl = Response.ApplyAppPathModifier("~/Pages/Link/ListLinks.aspx?userId=" + link.UserId); lblMovie.Text = ApplicationManager.GetMovieTitle(link.MovieId); if (searchEngine == "webshop") { lnkMovie.NavigateUrl = Response.ApplyAppPathModifier("~/Pages/Movie/Movie.aspx?movieId=" + link.MovieId); } else { lnkMovie.NavigateUrl = Response.ApplyAppPathModifier("~/Pages/Movie/MovieXml.aspx?movieId=" + link.MovieId); } lblDate.Text = link.Date.ToString(); lblDescription.Text = link.Description; lblRating.Text = link.Rating.ToString(); lnkFavorite.NavigateUrl = Response.ApplyAppPathModifier("~/Pages/Favorite/AddFavorite.aspx?linkId=" + LinkId); lnkEditLink.NavigateUrl = Response.ApplyAppPathModifier("~/Pages/Link/EditLink.aspx?linkId=" + LinkId); lnkRemoveLink.NavigateUrl = Response.ApplyAppPathModifier("~/Pages/Link/RemoveLink.aspx?linkId=" + LinkId); lnkComments.NavigateUrl = Response.ApplyAppPathModifier("~/Pages/Comment/ListComments.aspx?linkId=" + LinkId); lnkAddComment.NavigateUrl = Response.ApplyAppPathModifier("~/Pages/Comment/AddComment.aspx?linkId=" + LinkId); if (SessionManager.IsUserAuthenticated(Context)) { UserSession userSession = (UserSession)this.Context.Session["userSession"]; long userId = userSession.UserProfileId; lnkRateUp.Enabled = (link.UserId != userId); lnkRateDown.Enabled = (link.UserId != userId); int ratedValue = ratingService.GetRating(userId, LinkId); if (ratedValue > 0) { lnkRateUp.CssClass += " selected"; } else if (ratedValue < 0) { lnkRateDown.CssClass += " selected"; } lnkFavorite.Enabled = (link.UserId != userId); if (favoriteService.HasInFavorites(userId, LinkId)) { lnkFavorite.ImageUrl = (string)GetLocalResourceObject("lnkUnfavorite.ImageUrl"); lnkFavorite.Text = (string)GetLocalResourceObject("lnkUnfavorite.Text"); lnkFavorite.NavigateUrl = Response.ApplyAppPathModifier("~/Pages/Favorite/RemoveFavorite.aspx?linkId=" + LinkId); } lnkEditLink.Visible = (link.UserId == userId); lnkRemoveLink.Visible = (link.UserId == userId); lnkReported.Visible = (link.UserId == userId) && (link.Rating <= Settings.Default.WebMovies_demotedThreshold) && (!link.ReportRead); } if (link.Rating <= Settings.Default.WebMovies_demotedThreshold) { pLink.CssClass += " demoted"; } else if (link.Rating >= Settings.Default.WebMovies_promotedThreshold) { pLink.CssClass += " promoted"; } UpdateLabels(); } }