public async Task <IActionResult> OnPostCleanMundexCacheAsync() { using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { HttpResponseMessage response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/ganjoor/page/cache/64899");// =>/mundex if (!response.IsSuccessStatusCode) { return(BadRequest(JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()))); } response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/ganjoor/page/cache/70833");// =>mundex/bypoet if (!response.IsSuccessStatusCode) { return(BadRequest(JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()))); } return(new OkObjectResult(true)); } } return(new OkObjectResult(false)); }
public async Task <IActionResult> OnPostAsync(GanjoorPoemCompleteViewModel Poem) { LastMessage = ""; using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { int probableRecordId = Poem.GanjoorMetre.Id; string metre = Poem.GanjoorMetre.Rhythm; if (string.IsNullOrEmpty(metre)) { LastMessage = "وزنی انتخاب نشده."; return(Page()); } var response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/probablemetre/save/{probableRecordId}", new StringContent(JsonConvert.SerializeObject(metre), Encoding.UTF8, "application/json") ); if (!response.IsSuccessStatusCode) { LastMessage = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); } else { return(Redirect($"/Admin/Probables")); } } else { LastMessage = "لطفا از گنجور خارج و مجددا به آن وارد شوید."; } } return(Page()); }
public async Task <IActionResult> OnPostAsync() { LastResult = ""; using (HttpClient secureClient = new HttpClient()) { await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response); HttpResponseMessage response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/ganjoor/poet/{Request.Query["id"]}"); if (!response.IsSuccessStatusCode) { LastResult = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); return(Page()); } var cacheKey1 = $"/api/ganjoor/poets"; if (_memoryCache.TryGetValue(cacheKey1, out List <GanjoorPoetViewModel> poets)) { _memoryCache.Remove(cacheKey1); } var cacheKey2 = $"/api/ganjoor/poet/{Request.Query["id"]}"; if (_memoryCache.TryGetValue(cacheKey2, out GanjoorPoetCompleteViewModel poet)) { _memoryCache.Remove(cacheKey2); } LastResult = "عملیات حذف شاعر شروع شد."; return(Page()); } }
public async Task <IActionResult> OnPostDismissAsync(GanjoorPoemCompleteViewModel Poem) { LastMessage = ""; using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { int probableRecordId = Poem.GanjoorMetre.Id; var response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/ganjoor/probablemetre/dismiss/{probableRecordId}"); if (!response.IsSuccessStatusCode) { LastMessage = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); } else { return(Redirect($"/Admin/Probables")); } } else { LastMessage = "لطفا از گنجور خارج و مجددا به آن وارد شوید."; } } return(Page()); }
public async Task <IActionResult> OnGetAsync() { if (string.IsNullOrEmpty(Request.Cookies["Token"])) { return(Redirect("/")); } using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { var userInfoResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/users/{Request.Query["id"]}"); if (userInfoResponse.IsSuccessStatusCode) { UserInfo = JsonConvert.DeserializeObject <PublicRAppUser>(await userInfoResponse.Content.ReadAsStringAsync()); UserCauseViewModel = new UserCauseViewModel() { UserId = (Guid)UserInfo.Id, Cause = "نقض قوانین حاشیهگذاری" }; } else { LastResult = JsonConvert.DeserializeObject <string>(await userInfoResponse.Content.ReadAsStringAsync()); } } else { LastResult = "لطفا از گنجور خارج و مجددا به آن وارد شوید."; } } return(Page()); }
public async Task <ActionResult> OnPostSavePoetMetaAsync(int id, int birth, int death, int pinorder, bool validbirth, bool validdeath, string birthlocation, string deathlocation) { using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { var poet = new GanjoorPoetViewModel() { Id = id, BirthYearInLHijri = birth, DeathYearInLHijri = death, PinOrder = pinorder, ValidBirthDate = validbirth, ValidDeathDate = validdeath, BirthPlace = birthlocation, DeathPlace = deathlocation }; var response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/poet/{id}", new StringContent(JsonConvert.SerializeObject(poet), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { return(BadRequest(JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()))); } _memoryCache.Remove($"/api/ganjoor/poets"); _memoryCache.Remove($"/api/ganjoor/poet/{id}"); return(new OkObjectResult(true)); } } return(new OkObjectResult(false)); }
public async Task <ActionResult> OnPostAddToMyHistoryAsync(int poemId) { using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { HttpResponseMessage response = await secureClient.PostAsync( $"{APIRoot.Url}/api/tracking", new StringContent(JsonConvert.SerializeObject(poemId), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { return(new BadRequestObjectResult(JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()))); } var res = JsonConvert.DeserializeObject <bool>(await response.Content.ReadAsStringAsync()); if (res == false) { if (Request.Cookies["KeepHistory"] != null) { Response.Cookies.Delete("KeepHistory"); } var cookieOption = new CookieOptions() { Expires = DateTime.Now.AddDays(365), }; Response.Cookies.Append("KeepHistory", $"{false}", cookieOption); } return(new OkObjectResult(res)); } else { return(new BadRequestObjectResult("لطفا از گنجور خارج و مجددا به آن وارد شوید.")); } } }
/// <summary> /// تغییر عنوان گروهی /// </summary> /// <param name="NamingModel"></param> /// <returns></returns> public async Task <IActionResult> OnPostAsync(GanjoorBatchNamingModel NamingModel) { await GetInformationAsync(); NumberingModel = new GanjoorNumbering() { Name = Cat.Cat.Title, StartCatId = Cat.Cat.Id, EndCatId = Cat.Cat.Id }; using (HttpClient secureClient = new HttpClient()) { await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response); HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/recaptionpoems/{Cat.Cat.Id}", new StringContent(JsonConvert.SerializeObject(NamingModel), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { LastMessage = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); } else { RenamingOutput = JsonConvert.DeserializeObject <string[]>(await response.Content.ReadAsStringAsync()); } NamingModel.Simulate = false; } return(Page()); }
public async Task <IActionResult> OnPostSendEmailAsync(SelfDeleteViewModel deleteViewModel) { Step1 = true; FatalError = ""; using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { deleteViewModel.CallbackUrl = $"{_configuration["SiteUrl"]}/User/DeleteAccount"; HttpResponseMessage response = await secureClient.PostAsync( $"{APIRoot.Url}/api/users/selfdelete/start", new StringContent(JsonConvert.SerializeObject(deleteViewModel), Encoding.UTF8, "application/json" )); if (!response.IsSuccessStatusCode) { FatalError = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); } else { Step1 = false; } } else { FatalError = "لطفا از گنجور خارج و مجددا به آن وارد شوید."; } } return(Page()); }
public async Task <IActionResult> OnPostAsync() { using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { var putResponse = await secureClient.PostAsync($"{APIRoot.Url}/api/ganjoor/song/add", new StringContent(JsonConvert.SerializeObject(PoemMusicTrackViewModel), Encoding.UTF8, "application/json")); if (!putResponse.IsSuccessStatusCode) { LastError = JsonConvert.DeserializeObject <string>(await putResponse.Content.ReadAsStringAsync()); } } else { LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید."; } } if (!string.IsNullOrEmpty(LastError)) { return(Page()); } return(Redirect("/User/AddSong")); }
public async Task <IActionResult> OnPostAsync() { LastError = ""; Skip = string.IsNullOrEmpty(Request.Query["skip"]) ? 0 : int.Parse(Request.Query["skip"]); using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { var imageResponse = await secureClient.PutAsync($"{APIRoot.Url}/api/artifacts/ganjoor/sync/{ImageLinkFinalizeModel.Id}/{ImageLinkFinalizeModel.DisplayOnPage}", null); if (!imageResponse.IsSuccessStatusCode) { LastError = await imageResponse.Content.ReadAsStringAsync(); } else { return(Redirect($"/User/FinalizeImages/?skip={Skip}")); } } else { LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید."; } } return(Page()); }
public async Task <IActionResult> OnPostAsync() { LastResult = ""; using (HttpClient secureClient = new HttpClient()) { await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response); HttpResponseMessage response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/ganjoor/page/cache/{Request.Query["id"]}"); if (!response.IsSuccessStatusCode) { LastResult = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); return(Page()); } response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/ganjoor/page/{Request.Query["id"]}"); if (!response.IsSuccessStatusCode) { LastResult = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); } else { LastResult = "عملیات حذف صفحه انجام شد."; } return(Page()); } }
public async Task <IActionResult> OnGetAsync() { if (string.IsNullOrEmpty(Request.Cookies["Token"])) { return(Redirect("/")); } LastMessage = ""; using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { var response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/page/oldversions/{Request.Query["id"]}"); if (!response.IsSuccessStatusCode) { LastMessage = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); return(Page()); } OlderVersions = JsonConvert.DeserializeObject <GanjoorPageSnapshotSummaryViewModel[]>(await response.Content.ReadAsStringAsync()); } else { LastMessage = "لطفا از گنجور خارج و مجددا به آن وارد شوید."; } } return(Page()); }
/// <summary> /// edit /// </summary> /// <returns></returns> public async Task <IActionResult> OnPutEditAsync(int id, string alt, string url, bool active) { LastMessage = ""; using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { GanjoorSiteBannerModifyViewModel model = new GanjoorSiteBannerModifyViewModel() { AlternateText = alt, TargetUrl = url, Active = active }; HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/banners/{id}", new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { return(new BadRequestObjectResult(JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()))); } } else { return(new BadRequestObjectResult("لطفا از گنجور خارج و مجددا به آن وارد شوید.")); } } return(new JsonResult(true)); }
public async Task <IActionResult> OnPostSetMyInfoAsync(RegisterRAppUser UserInfo) { LastError = ""; PasswordChanged = ""; using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { var isAdminResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/users/isadmin?userId={Request.Cookies["UserId"]}"); if (isAdminResponse.IsSuccessStatusCode) { UserInfo.IsAdmin = JsonConvert.DeserializeObject <bool>(await isAdminResponse.Content.ReadAsStringAsync()); var putResponse = await secureClient.PutAsync($"{APIRoot.Url}/api/users/{Request.Cookies["UserId"]}", new StringContent(JsonConvert.SerializeObject(UserInfo), Encoding.UTF8, "application/json")); if (!putResponse.IsSuccessStatusCode) { LastError = JsonConvert.DeserializeObject <string>(await putResponse.Content.ReadAsStringAsync()); } } else { LastError = await isAdminResponse.Content.ReadAsStringAsync(); } } else { LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید."; } } await _PreparePage(); return(Page()); }
public async Task <IActionResult> OnPostAsync() { LastMessage = ""; using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { HttpResponseMessage response = await secureClient.PostAsync($"{APIRoot.Url}/api/translations/languages", new StringContent(JsonConvert.SerializeObject(Language), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { LastMessage = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); } else { return(await OnGetAsync()); } } else { LastMessage = "لطفا از گنجور خارج و مجددا به آن وارد شوید."; } } return(Page()); }
public async Task <IActionResult> OnPostStartTracking() { using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { var response = await secureClient.PutAsync($"{APIRoot.Url}/api/tracking", new StringContent(JsonConvert.SerializeObject(true), Encoding.UTF8, "application/json")); if (response.StatusCode != HttpStatusCode.OK) { return(new BadRequestObjectResult(JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()))); } if (Request.Cookies["KeepHistory"] != null) { Response.Cookies.Delete("KeepHistory"); } var cookieOption = new CookieOptions() { Expires = DateTime.Now.AddDays(365), }; Response.Cookies.Append("KeepHistory", $"{true}", cookieOption); } else { return(new BadRequestObjectResult("لطفا از گنجور خارج و مجددا به آن وارد شوید.")); } } return(new JsonResult(true)); }
public async Task <IActionResult> OnPutChoosePhotoAsync(int id) { using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { var responsePhoto = await secureClient.GetAsync($"{APIRoot.Url}/api/poetphotos/{id}"); if (!responsePhoto.IsSuccessStatusCode) { LastError = JsonConvert.DeserializeObject <string>(await responsePhoto.Content.ReadAsStringAsync()); return(new BadRequestObjectResult(LastError)); } var photo = JsonConvert.DeserializeObject <GanjoorPoetSuggestedPictureViewModel>(await responsePhoto.Content.ReadAsStringAsync()); photo.ChosenOne = true; var response = await secureClient.PutAsync($"{APIRoot.Url}/api/poetphotos", new StringContent(JsonConvert.SerializeObject(photo), Encoding.UTF8, "application/json")); if (response.StatusCode != HttpStatusCode.OK) { return(new BadRequestObjectResult(JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()))); } } else { return(new BadRequestObjectResult("لطفا از گنجور خارج و مجددا به آن وارد شوید.")); } } return(new OkResult()); }
private async Task ReadExpenses() { var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/donations/expense"); if (!response.IsSuccessStatusCode) { LastMessage = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); return; } Expenses = JsonConvert.DeserializeObject <GanjoorExpense[]>(await response.Content.ReadAsStringAsync()); using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { HttpResponseMessage resAccountInfo = await secureClient.GetAsync($"{APIRoot.Url}/api/donations/accountinfo/visible"); if (!resAccountInfo.IsSuccessStatusCode) { LastMessage = await resAccountInfo.Content.ReadAsStringAsync(); return; } ShowAccountInfo = JsonConvert.DeserializeObject <bool>(await resAccountInfo.Content.ReadAsStringAsync()) ? "نمایش حساب فعال است." : "نمایش حساب غیرفعال است."; } } }
public async Task <IActionResult> OnGetAsync() { if (string.IsNullOrEmpty(Request.Cookies["Token"])) { return(Redirect("/")); } LastMessage = ""; using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { var response = await secureClient.GetAsync($"{APIRoot.Url}/api/rjobs"); if (!response.IsSuccessStatusCode) { LastMessage = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); return(Page()); } Jobs = JsonConvert.DeserializeObject <RLongRunningJobStatus[]>(await response.Content.ReadAsStringAsync()); } } return(Page()); }
public async Task <IActionResult> OnPutEditAsync(int id, string name, double latitude, double longitude) { using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { GanjoorGeoLocation model = new GanjoorGeoLocation() { Id = id, Name = name, Latitude = latitude, Longitude = longitude }; HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/locations", new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { return(new BadRequestObjectResult(JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()))); } } else { return(new BadRequestObjectResult("لطفا از گنجور خارج و مجددا به آن وارد شوید.")); } } return(new JsonResult(true)); }
public async Task <IActionResult> OnPostBreakPoemAsync(int poemId, int vOrder) { using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { HttpResponseMessage response = await secureClient.PostAsync( $"{APIRoot.Url}/api/ganjoor/poem/break", new StringContent(JsonConvert.SerializeObject ( new PoemVerseOrder() { PoemId = poemId, VOrder = vOrder } ), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { return(new BadRequestObjectResult(JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()))); } return(new OkObjectResult(JsonConvert.DeserializeObject <int>(await response.Content.ReadAsStringAsync()))); } else { return(new BadRequestObjectResult("لطفا از گنجور خارج و مجددا به آن وارد شوید.")); } } }
public async Task <IActionResult> OnPostNumberingAsync(GanjoorNumbering NumberingModel) { using (HttpClient secureClient = new HttpClient()) { await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response); HttpResponseMessage response = await secureClient.PostAsync($"{APIRoot.Url}/api/numberings", new StringContent(JsonConvert.SerializeObject(NumberingModel), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { LastMessage = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); } } await GetInformationAsync(); NamingModel = new GanjoorBatchNamingModel() { StartWithNotIncludingSpaces = "شمارهٔ ", RemovePreviousPattern = true, RemoveSetOfCharacters = ".-", Simulate = true }; return(Page()); }
public async Task <IActionResult> OnPostAsync(GanjoorDonationViewModel Donation) { LastMessage = ""; using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { Donation.ImportedRecord = false; HttpResponseMessage response = await secureClient.PostAsync($"{APIRoot.Url}/api/donations", new StringContent(JsonConvert.SerializeObject(Donation), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { LastMessage = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); } else { await ReadDonations(); EmailContent = $"با درود و سپاس از بزرگواری شما{Environment.NewLine}" + $"کمک دریافتی به شماره ردیف {Donations.Length.ToPersianNumbers()} در این نشانی ثبت شد:{Environment.NewLine}" + $"https://ganjoor.net/donate{Environment.NewLine}" + $"نحوهٔ هزینه شدن آن متعاقباً در همان ردیف مستند خواهد شد.{Environment.NewLine}" + $"سرافراز باشید."; } } else { LastMessage = "لطفا از گنجور خارج و مجددا به آن وارد شوید."; } } return(Page()); }
public async Task <IActionResult> OnPostAsync() { PostSuccess = false; LastError = ""; LoggedIn = !string.IsNullOrEmpty(Request.Cookies["Token"]); using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { var stringContent = new StringContent(JsonConvert.SerializeObject(Report), Encoding.UTF8, "application/json"); var methodUrl = $"{APIRoot.Url}/api/ganjoor/comment/report"; var response = await secureClient.PostAsync(methodUrl, stringContent); if (!response.IsSuccessStatusCode) { LastError = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); } else { PostSuccess = true; } } else { LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید."; } } return(Page()); }
public async Task <IActionResult> OnPostEditPoetAsync(GanjoorPoetViewModel Poet) { LastResult = ""; using (HttpClient secureClient = new HttpClient()) { await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response); if (Request.Query["id"].ToString() == "0") { HttpResponseMessage response = await secureClient.PostAsync($"{APIRoot.Url}/api/ganjoor/poet", new StringContent(JsonConvert.SerializeObject(Poet), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { LastResult = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); return(Page()); } var poet = JsonConvert.DeserializeObject <GanjoorPoetCompleteViewModel>(await response.Content.ReadAsStringAsync()); var cacheKey1 = $"/api/ganjoor/poets"; if (_memoryCache.TryGetValue(cacheKey1, out List <GanjoorPoetViewModel> poets)) { _memoryCache.Remove(cacheKey1); } return(Redirect($"/Admin/Poet?id={poet.Poet.Id}")); } else { HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/poet/{Request.Query["id"]}", new StringContent(JsonConvert.SerializeObject(Poet), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { LastResult = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); return(Page()); } var cacheKey1 = $"/api/ganjoor/poets"; if (_memoryCache.TryGetValue(cacheKey1, out List <GanjoorPoetViewModel> poets)) { _memoryCache.Remove(cacheKey1); } var cacheKey2 = $"/api/ganjoor/poet/{Request.Query["id"]}"; if (_memoryCache.TryGetValue(cacheKey2, out GanjoorPoetCompleteViewModel poet)) { _memoryCache.Remove(cacheKey2); } LastResult = $"ویرایش انجام شد. <a role=\"button\" href=\"/Admin/Poet?id={Request.Query["id"]}\" class=\"actionlink\">برگشت به صفحهٔ ویرایش شاعر</a>"; await PreparePoet(); return(Page()); } } }
public async Task <IActionResult> OnGetAsync() { if (string.IsNullOrEmpty(Request.Cookies["Token"])) { return(Redirect("/")); } LastError = ""; Skip = string.IsNullOrEmpty(Request.Query["skip"]) ? 0 : int.Parse(Request.Query["skip"]); MainImage = null; PreviouslyLinkedImage = null; using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { var imageResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/artifacts/ganjoor/nextunsychedimage?skip={Skip}"); if (!imageResponse.IsSuccessStatusCode) { LastError = await imageResponse.Content.ReadAsStringAsync(); } else { string paginnationMetadata = imageResponse.Headers.GetValues("paging-headers").FirstOrDefault(); if (!string.IsNullOrEmpty(paginnationMetadata)) { TotalCount = JsonConvert.DeserializeObject <PaginationMetadata>(paginnationMetadata).totalCount; } var images = JsonConvert.DeserializeObject <GanjoorLinkViewModel[]>(await imageResponse.Content.ReadAsStringAsync()); if (images != null) { if (images.Length >= 1) { MainImage = images[0]; ImageLinkFinalizeModel = new ImageLinkFinalizeModel() { Id = MainImage.Id, DisplayOnPage = false }; } if (images.Length >= 2) { PreviouslyLinkedImage = images[1]; } } } } else { LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید."; } } return(Page()); }
public async Task <IActionResult> OnGetAsync() { if (string.IsNullOrEmpty(Request.Cookies["Token"])) { return(Redirect("/")); } LastMessage = ""; await GanjoorSessionChecker.ApplyPermissionsToViewData(Request, Response, ViewData); if (!ViewData.ContainsKey($"{RMuseumSecurableItem.FAQEntityShortName}-{RMuseumSecurableItem.ModerateOperationShortName}")) { LastMessage = "شما به این بخش دسترسی ندارید."; return(Page()); } CatId = 0; using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) { HttpResponseMessage response = await secureClient.GetAsync($"{APIRoot.Url}/api/faq/cat/secure"); if (!response.IsSuccessStatusCode) { LastMessage = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); return(Page()); } Categories = JsonConvert.DeserializeObject <FAQCategory[]>(await response.Content.ReadAsStringAsync()); if (Categories.Length > 0) { CatId = string.IsNullOrEmpty(Request.Query["catId"]) ? Categories[0].Id : int.Parse(Request.Query["catId"]); response = await secureClient.GetAsync($"{APIRoot.Url}/api/faq/cat/items/secure?catId={CatId}"); if (!response.IsSuccessStatusCode) { return(new BadRequestObjectResult(JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()))); } CategoryItems = JsonConvert.DeserializeObject <FAQItem[]>(await response.Content.ReadAsStringAsync()); } } else { LastMessage = "لطفا از گنجور خارج و مجددا به آن وارد شوید."; } } return(Page()); }
public async Task <IActionResult> OnPostAsync() { PostSuccess = false; LastError = ""; LoggedIn = !string.IsNullOrEmpty(Request.Cookies["Token"]); RecitationInfo = ""; if (string.IsNullOrEmpty(Report.ReasonText)) { LastError = "مشکل مشخص نشده است. "; return(Page()); } Report.ReasonText = Report.ReasonText.Trim(); if (string.IsNullOrEmpty(Report.ReasonText)) { LastError = "مشکل مشخص نشده است. "; return(Page()); } if (Report.NumberOfLinesAffected < 1) { Report.NumberOfLinesAffected = 1; } using (HttpClient _httpClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(_httpClient, Request, Response)) { var stringContent = new StringContent(JsonConvert.SerializeObject(Report), Encoding.UTF8, "application/json"); var methodUrl = $"{APIRoot.Url}/api/audio/errors/report"; var response = await _httpClient.PostAsync(methodUrl, stringContent); if (!response.IsSuccessStatusCode) { LastError = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); } else { PostSuccess = true; } } else { LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید."; } } return(Page()); }
public async Task <IActionResult> OnPostAsync() { Skip = string.IsNullOrEmpty(Request.Query["skip"]) ? 0 : int.Parse(Request.Query["skip"]); if (Request.Form["next"].Count == 1) { return(Redirect($"/User/ReviewSongs/?skip={Skip + 1}")); } PoemMusicTrackViewModel.Approved = Request.Form["approve"].Count == 1; PoemMusicTrackViewModel.Rejected = (Request.Form["reject1"].Count + Request.Form["reject2"].Count + Request.Form["reject3"].Count) > 0; if (string.IsNullOrEmpty(PoemMusicTrackViewModel.RejectionCause)) { if (Request.Form["reject1"].Count == 1) { PoemMusicTrackViewModel.RejectionCause = "در آهنگ این شعر خوانده نشده"; } else if (Request.Form["reject2"].Count == 1) { PoemMusicTrackViewModel.RejectionCause = "لینک یا اطلاعات آهنگ ایراد دارد"; } } using (HttpClient client = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(client, Request, Response)) { var putResponse = await client.PutAsync($"{APIRoot.Url}/api/ganjoor/song", new StringContent(JsonConvert.SerializeObject(PoemMusicTrackViewModel), Encoding.UTF8, "application/json")); if (!putResponse.IsSuccessStatusCode) { LastError = await putResponse.Content.ReadAsStringAsync(); } } else { LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید."; } } if (!string.IsNullOrEmpty(LastError)) { return(Page()); } return(Redirect($"/User/ReviewSongs/?skip={Skip}")); }