From 6d0395998d4c5fa65d29758a831c0fb080971cfa Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Sat, 24 Jul 2021 20:51:05 +0430 Subject: [PATCH] #185 preventing bp suggestion tool to work under read only mode --- GanjooRazor/Pages/Bp.cshtml | 13 ++++++++++++- GanjooRazor/Pages/Bp.cshtml.cs | 21 ++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/GanjooRazor/Pages/Bp.cshtml b/GanjooRazor/Pages/Bp.cshtml index b5eb8ae2..56a5d77d 100644 --- a/GanjooRazor/Pages/Bp.cshtml +++ b/GanjooRazor/Pages/Bp.cshtml @@ -36,6 +36,17 @@
+ @if (Model.ReadOnlyMode) + { +
+
+

+ امکان پیشنهاد قطعه موقتا به دلیل تغییرات سایت و یا انتقال سرور وجود ندارد. لطفاً ساعاتی دیگر مجدداً تلاش کنید. +

+
+
+ } + else @if (Model.PoemId == 0) {
@@ -47,7 +58,7 @@
} else - if (!Model.LoggedIn) + if (!Model.LoggedIn) {
diff --git a/GanjooRazor/Pages/Bp.cshtml.cs b/GanjooRazor/Pages/Bp.cshtml.cs index 1ce7fbdf..0aff349f 100644 --- a/GanjooRazor/Pages/Bp.cshtml.cs +++ b/GanjooRazor/Pages/Bp.cshtml.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.ViewFeatures; +using Microsoft.Extensions.Configuration; using Newtonsoft.Json; using RMuseum.Models.Ganjoor; using RMuseum.Models.Ganjoor.ViewModels; @@ -25,13 +26,20 @@ namespace GanjooRazor.Pages /// private readonly HttpClient _httpClient; + /// + /// configuration + /// + private readonly IConfiguration Configuration; + /// /// constructor /// /// - public BpModel(HttpClient httpClient) + /// + public BpModel(HttpClient httpClient, IConfiguration configuration) { _httpClient = httpClient; + Configuration = configuration; } /// @@ -60,6 +68,17 @@ namespace GanjooRazor.Pages /// public int InsertedSongId { get; set; } + /// + /// readonly mode + /// + public bool ReadOnlyMode + { + get + { + return bool.Parse(Configuration["ReadOnlyMode"]); + } + } + /// /// suggested (unapproved) songs ///