private void BindData() { var pm = ForumManager.GetPrivateMessageById(this.PrivateMessageId); if (pm != null) { if (pm.ToUserId != NopContext.Current.User.CustomerId && pm.FromUserId != NopContext.Current.User.CustomerId) { Response.Redirect(CommonHelper.GetStoreLocation() + "privatemessages.aspx"); } if (!pm.IsRead && pm.ToUserId == NopContext.Current.User.CustomerId) { pm = ForumManager.UpdatePrivateMessage(pm.PrivateMessageId, pm.FromUserId, pm.ToUserId, pm.Subject, pm.Text, true, pm.IsDeletedByAuthor, pm.IsDeletedByRecipient, pm.CreatedOn); } } else { Response.Redirect(CommonHelper.GetStoreLocation() + "privatemessages.aspx"); } lblFrom.Text = Server.HtmlEncode(CustomerManager.FormatUserName(pm.FromUser)); lblTo.Text = Server.HtmlEncode(CustomerManager.FormatUserName(pm.ToUser)); lblSubject.Text = Server.HtmlEncode(pm.Subject); lblMessage.Text = ForumManager.FormatPrivateMessageText(pm.Text); }
private void BindData() { Customer toCustomer = null; var replyToPM = ForumManager.GetPrivateMessageById(this.ReplyToMessageId); if (replyToPM != null) { if (replyToPM.ToUserId == NopContext.Current.User.CustomerId || replyToPM.FromUserId == NopContext.Current.User.CustomerId) { toCustomer = replyToPM.FromUser; txtSubject.Text = string.Format("Re: {0}", replyToPM.Subject); } else { Response.Redirect(CommonHelper.GetStoreLocation() + "privatemessages.aspx"); } } else { toCustomer = CustomerManager.GetCustomerById(this.ToCustomerId); } if (toCustomer == null || toCustomer.IsGuest) { Response.Redirect(CommonHelper.GetStoreLocation() + "privatemessages.aspx"); } lblSendTo.Text = Server.HtmlEncode(CustomerManager.FormatUserName(toCustomer)); }
protected void btnSend_Click(object sender, EventArgs e) { try { string subject = txtSubject.Text.Trim(); string message = txtMessageBBCode.Text.Trim(); if (String.IsNullOrEmpty(subject)) { throw new NopException(GetLocaleResourceString("PrivateMessages.SubjectCannotBeEmpty")); } if (String.IsNullOrEmpty(message)) { throw new NopException(GetLocaleResourceString("PrivateMessages.MessageCannotBeEmpty")); } Customer toCustomer = null; var replyToPM = ForumManager.GetPrivateMessageById(this.ReplyToMessageId); if (replyToPM != null) { if (replyToPM.ToUserId == NopContext.Current.User.CustomerId || replyToPM.FromUserId == NopContext.Current.User.CustomerId) { toCustomer = replyToPM.FromUser; } else { Response.Redirect(CommonHelper.GetStoreLocation() + "privatemessages.aspx"); } } else { toCustomer = CustomerManager.GetCustomerById(this.ToCustomerId); } if (toCustomer == null || toCustomer.IsGuest) { Response.Redirect(CommonHelper.GetStoreLocation() + "privatemessages.aspx"); } var pm = ForumManager.InsertPrivateMessage(NopContext.Current.User.CustomerId, toCustomer.CustomerId, subject, message, false, false, false, DateTime.Now); Response.Redirect(CommonHelper.GetStoreLocation() + "privatemessages.aspx?tab=sent"); } catch (Exception exc) { pnlError.Visible = true; lErrorMessage.Text = Server.HtmlEncode(exc.Message); } }
protected void btnReply_Click(object sender, EventArgs e) { var pm = ForumManager.GetPrivateMessageById(this.PrivateMessageId); if (pm != null) { string replyURL = string.Format("{0}sendpm.aspx?r={1}", CommonHelper.GetStoreLocation(), pm.PrivateMessageId); Response.Redirect(replyURL); } else { Response.Redirect(CommonHelper.GetStoreLocation() + "privatemessages.aspx"); } }
protected void btnDelete_Click(object sender, EventArgs e) { var pm = ForumManager.GetPrivateMessageById(this.PrivateMessageId); if (pm != null) { if (pm.FromUserId == NopContext.Current.User.CustomerId) { pm = ForumManager.UpdatePrivateMessage(pm.PrivateMessageId, pm.FromUserId, pm.ToUserId, pm.Subject, pm.Text, pm.IsRead, true, pm.IsDeletedByRecipient, pm.CreatedOn); } if (pm != null) { if (pm.ToUserId == NopContext.Current.User.CustomerId) { pm = ForumManager.UpdatePrivateMessage(pm.PrivateMessageId, pm.FromUserId, pm.ToUserId, pm.Subject, pm.Text, pm.IsRead, pm.IsDeletedByAuthor, true, pm.CreatedOn); } } } Response.Redirect(CommonHelper.GetStoreLocation() + "privatemessages.aspx"); }
protected void btnDeleteSelected_Click(object sender, EventArgs e) { if (Page.IsValid) { try { foreach (GridViewRow row in gvSent.Rows) { var cbSelect = row.FindControl("cbSelect") as CheckBox; var hfPrivateMessageId = row.FindControl("hfPrivateMessageId") as HiddenField; if (cbSelect != null && hfPrivateMessageId != null) { bool selected = cbSelect.Checked; int pmId = int.Parse(hfPrivateMessageId.Value); if (selected) { var pm = ForumManager.GetPrivateMessageById(pmId); if (pm != null) { if (pm.FromUserId == NopContext.Current.User.CustomerId) { pm = ForumManager.UpdatePrivateMessage(pm.PrivateMessageId, pm.FromUserId, pm.ToUserId, pm.Subject, pm.Text, pm.IsRead, true, pm.IsDeletedByRecipient, pm.CreatedOn); } } } } } Response.Redirect(CommonHelper.GetStoreLocation() + "privatemessages.aspx?tab=sent"); } catch (Exception exc) { LogManager.InsertLog(LogTypeEnum.CustomerError, exc.Message, exc); } } }