diff --git a/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoetViewModel.cs b/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoetViewModel.cs index 6e8345ce..800f562d 100644 --- a/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoetViewModel.cs +++ b/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoetViewModel.cs @@ -100,6 +100,16 @@ /// public double DeathPlaceLongitude { get; set; } + /// + /// tajik nick name + /// + public string TajikNickName { get; set; } + + /// + /// additional descripion or note in Tajik + /// + public string TajikDescription { get; set; } + public override string ToString() { return Nickname; diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index c65aa5a6..cf0938aa 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -12030,6 +12030,16 @@ death place longitude + + + tajik nick name + + + + + additional descripion or note in Tajik + + report comment view model diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index 8ab1095d..d35c5cd0 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -80,6 +80,8 @@ namespace RMuseum.Services.Implementation DeathPlaceLatitude = poet.DeathLocation == null ? 0 : poet.DeathLocation.Latitude, DeathPlaceLongitude = poet.DeathLocation == null ? 0 : poet.DeathLocation.Longitude, PinOrder = poet.PinOrder, + TajikNickName = poet.TajikNickName, + TajikDescription = poet.TajikDescription, } ) .AsNoTracking() @@ -471,6 +473,8 @@ namespace RMuseum.Services.Implementation DeathPlace = poet.DeathLocation == null ? "" : poet.DeathLocation.Name, DeathPlaceLatitude = poet.DeathLocation == null ? 0 : poet.DeathLocation.Latitude, DeathPlaceLongitude = poet.DeathLocation == null ? 0 : poet.DeathLocation.Longitude, + TajikNickName = poet.TajikNickName, + TajikDescription = poet.TajikDescription, }).AsNoTracking().FirstOrDefaultAsync(), Cat = catViewModel } @@ -631,6 +635,8 @@ namespace RMuseum.Services.Implementation ValidDeathDate = poet.ValidDeathDate, DeathYearInLHijri = poet.DeathYearInLHijri, PinOrder = poet.PinOrder, + TajikNickName = poet.TajikNickName, + TajikDescription = poet.TajikDescription, } ) .AsNoTracking().SingleAsync(); diff --git a/TajikGanjoor/Pages/Index.cshtml b/TajikGanjoor/Pages/Index.cshtml index 46d3e453..995469a6 100644 --- a/TajikGanjoor/Pages/Index.cshtml +++ b/TajikGanjoor/Pages/Index.cshtml @@ -1,13 +1,27 @@ @page @model IndexModel @{ - ViewData["Title"] = "Home page"; + ViewData["Title"] = "Ганҷур"; +} + +@if(!string.IsNullOrEmpty(Model.LastError)) +{ + @Html.Raw(Model.LastError) + return; +} + +@if(Model.Poets == null) +{ +

+ Хато дар дарёфт феҳристи суханварон +

+ return; }

Ганҷур

@foreach(var poet in Model.Poets) { -

@poet.Nickname

+

@poet.TajikNickName

}
diff --git a/TajikGanjoor/Pages/Index.cshtml.cs b/TajikGanjoor/Pages/Index.cshtml.cs index 9c2ad7e9..94622559 100644 --- a/TajikGanjoor/Pages/Index.cshtml.cs +++ b/TajikGanjoor/Pages/Index.cshtml.cs @@ -10,7 +10,7 @@ namespace TajikGanjoor.Pages { public class IndexModel : PageModel { - public List Poets { get; set; } + public List? Poets { get; set; } public async Task OnGetAsync() { @@ -24,11 +24,6 @@ namespace TajikGanjoor.Pages return Page(); } - foreach (var poet in Poets) - { - poet.Nickname = TajikTransilerator.Transilerate(poet.Nickname); - } - return Page(); } @@ -63,7 +58,7 @@ namespace TajikGanjoor.Pages return true; } - public string LastError { get; set; } + public string? LastError { get; set; } public bool AggressiveCacheEnabled { diff --git a/TajikGanjoor/TajikTransilerator.cs b/TajikGanjoor/TajikTransilerator.cs deleted file mode 100644 index fd8fe69c..00000000 --- a/TajikGanjoor/TajikTransilerator.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Net; -using System.Text; -using System.Web; - -namespace TajikGanjoor -{ - public static class TajikTransilerator - { - public static string Transilerate(string input) - { - string txt = "ctl00%24ContentPlaceHolder2%24ScriptManager1=ctl00%24ContentPlaceHolder2%24UpdatePanel1%7Cctl00%24ContentPlaceHolder2%24btnConvert&__EVENTTARGET=&__EVENTARGUMENT=&ctl00%24ContentPlaceHolder2%24txtPersian=%D8%AD%D8%B3%D9%86&ctl00%24ContentPlaceHolder2%24txtSuggest=&__VIEWSTATE=FJBM71Nf2Mzx%2BAjVP0LDLRQCvG%2FugjscaiM7gw%2FgpSEoehbsWEMsC7oirmYVtQOUfi54eqgLZgamFYJBb1aYL%2F14dcixVbv1QXAiL9MM6etgOF2vr6c%2FWRXq%2FGJG2cHi2RB8WjgX%2FCUwp2H%2F3DmyVIY4l24XTb8Y0Onu8oNXM5dbfxAs&__VIEWSTATEGENERATOR=82B657B9&__EVENTVALIDATION=y6DlG61vZjyA%2B6t19Hfyomarliwfg8r%2FDo7E%2BXbLHgNT0mxwLpAsjMso%2FrXEsKomZQZRKOwE1s8PwY1aJVUDoiWEfnlLe9HNFndoQBA5UwX0LIHzVZez4spR534XJhre0pFd2PrCeJj35v9clTYrdBfiZ1hvyXAggj5iYlCWl56DVz8JfmNSXlsN2Wirik5DsTGXsw%3D%3D&__ASYNCPOST=true&ctl00%24ContentPlaceHolder2%24btnConvert=%D8%A8%D8%B1%DA%AF%D8%B1%D8%AF%D8%A7%D9%86"; - - txt = txt.Replace("%D8%AD%D8%B3%D9%86", HttpUtility.UrlEncode(input)); - - HttpWebRequest request = HttpWebRequest.Create("http://persian-tajik.ir/farsitotajiki.aspx") as HttpWebRequest; - - ASCIIEncoding ascii = new ASCIIEncoding(); - byte[] postBytes = ascii.GetBytes(txt); - - request.Method = "POST"; - request.ContentType = "application/x-www-form-urlencoded"; - request.ContentLength = postBytes.Length; - request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; - - // add post data to request - Stream postStream = request.GetRequestStream(); - postStream.Write(postBytes, 0, postBytes.Length); - postStream.Flush(); - postStream.Close(); - - var response = (HttpWebResponse)request.GetResponse(); - - var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); - - - int startIndex = responseString.IndexOf("ContentPlaceHolder2_txtCirlic"); - if (startIndex != -1) - { - int startDivIndex = responseString.IndexOf(">", startIndex); - if (startDivIndex != -1) - { - startDivIndex++; - } - - int endDivIndex = responseString.IndexOf("", startDivIndex); - - return responseString.Substring(startDivIndex, endDivIndex - startDivIndex).Replace("", "").Replace("", "").Trim(); - } - return input; - } - } -}