a small improvement on generating thank you emails text for donars
This commit is contained in:
parent
c6916743a3
commit
fa392dfca4
@ -2,13 +2,16 @@
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using DNTPersianUtils.Core;
|
||||
using GanjooRazor.Utils;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Newtonsoft.Json;
|
||||
using RMuseum.Models.Accounting.ViewModels;
|
||||
using RMuseum.Utils;
|
||||
|
||||
namespace GanjooRazor.Areas.Admin.Pages
|
||||
{
|
||||
@ -78,6 +81,7 @@ namespace GanjooRazor.Areas.Admin.Pages
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Request.Cookies["Token"]))
|
||||
@ -100,7 +104,16 @@ namespace GanjooRazor.Areas.Admin.Pages
|
||||
if(donation != null)
|
||||
{
|
||||
int rowNumber = Donations.Length - Array.IndexOf(Donations, donation);
|
||||
EmailContent = $"با درود به {donation.DonorName} عزیز و سپاس از بزرگواری شما{Environment.NewLine}" +
|
||||
string donorName = GanjoorPoemTools.StripHtmlTags(donation.DonorName);
|
||||
if(donorName.StartsWith("آقای"))
|
||||
{
|
||||
donorName = $"جناب {donorName}";
|
||||
}
|
||||
if (donorName.StartsWith("خانم"))
|
||||
{
|
||||
donorName = $"سرکار {donorName}";
|
||||
}
|
||||
EmailContent = $"با درود به {donorName} عزیز و سپاس از بزرگواری شما{Environment.NewLine}" +
|
||||
$"کمک دریافتی به شماره ردیف {rowNumber.ToPersianNumbers()} در این نشانی ثبت شد:{Environment.NewLine}" +
|
||||
$"https://ganjoor.net/donate{Environment.NewLine}" +
|
||||
$"نحوهٔ هزینه شدن آن متعاقباً در همان ردیف مستند خواهد شد.{Environment.NewLine}" +
|
||||
|
||||
@ -10,6 +10,7 @@ using System.Threading.Tasks;
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using RMuseum.Utils;
|
||||
|
||||
namespace GanjooRazor.Areas.User.Pages
|
||||
{
|
||||
@ -118,20 +119,13 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
return new BadRequestObjectResult("لطفاً از گنجور خارج و مجددا به آن وارد شوید.");
|
||||
}
|
||||
|
||||
static string StripHtmlTags(string input)
|
||||
{
|
||||
// Remove HTML tags using Regex
|
||||
string textWithoutTags = Regex.Replace(input, "<.*?>", string.Empty);
|
||||
|
||||
// Decode HTML entities (e.g., & → &)
|
||||
return HttpUtility.HtmlDecode(textWithoutTags);
|
||||
}
|
||||
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
Correction.Description = StripHtmlTags(Correction.DescriptionHtml);
|
||||
Correction.Description = GanjoorPoemTools.StripHtmlTags(Correction.DescriptionHtml);
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
namespace RMuseum.Utils
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
|
||||
namespace RMuseum.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// ganjoor poem tools
|
||||
@ -37,5 +40,14 @@
|
||||
|
||||
return poemHtml;
|
||||
}
|
||||
|
||||
public static string StripHtmlTags(string input)
|
||||
{
|
||||
// Remove HTML tags using Regex
|
||||
string textWithoutTags = Regex.Replace(input, "<.*?>", string.Empty);
|
||||
|
||||
// Decode HTML entities (e.g., & → &)
|
||||
return HttpUtility.HtmlDecode(textWithoutTags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user