diff --git a/Back/Controllers/BaseController.cs b/Back/Controllers/BaseController.cs index 7539d3e..fbd374e 100644 --- a/Back/Controllers/BaseController.cs +++ b/Back/Controllers/BaseController.cs @@ -31,6 +31,9 @@ namespace Back.Controllers return NotFound(); return Ok(result); } + [HttpGet("LastQuestion")] + public async Task>> LastQuestion(int PageIndex, int PageSize) + => Ok(await _sBase.GetQuestion(PageIndex, PageSize)); } } diff --git a/Back/Services/ServBase.cs b/Back/Services/ServBase.cs index 0788da2..0de2868 100644 --- a/Back/Services/ServBase.cs +++ b/Back/Services/ServBase.cs @@ -10,10 +10,12 @@ namespace Back.Services { private readonly IAsyncRepository _repoPricing; private readonly IAsyncRepository _repoBlog; - public ServBase(IAsyncRepository repoPricing, IAsyncRepository repoBlog) + private readonly IAsyncRepository _repoQuestion; + public ServBase(IAsyncRepository repoPricing, IAsyncRepository repoBlog, IAsyncRepository repoQuestion) { _repoPricing = repoPricing; _repoBlog = repoBlog; + _repoQuestion = repoQuestion; } public async Task> GetBasePrice() { @@ -37,6 +39,18 @@ namespace Back.Services Photo=string.IsNullOrEmpty(s.Photo) ? "blog-SampleTitle.jpg" : s.Photo }).Paging(PageIndex, PageSize); ; } + public async Task> GetQuestion(int PageIndex, int PageSize) + { + return await _repoQuestion.Get(w => w.Status) + .Include(inc=>inc.questionCategory).OrderByDescending(o => o.ID) + .Select(s => new QuestionDto + { + Answer=s.Answer, + Category=s.questionCategory.Title, + Title=s.Title, + ID = s.ID + }).Paging(PageIndex, PageSize); + } public async Task GetBlogByID(int ID) { var result= await _repoBlog.Get(w => w.Status && w.ID==ID) diff --git a/Shared/DTOs/QuestionDto.cs b/Shared/DTOs/QuestionDto.cs new file mode 100644 index 0000000..24dde13 --- /dev/null +++ b/Shared/DTOs/QuestionDto.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Shared.DTOs +{ + public class QuestionDto + { + public int ID { get; set; } + public string Category { get; set; } + public string Title { get; set; } + public string Answer { get; set; } + } +} diff --git a/TaxPayerFull/Layout/ItemBlog.razor b/TaxPayerFull/Layout/ItemBlog.razor index ffa3ba4..c33d2be 100644 --- a/TaxPayerFull/Layout/ItemBlog.razor +++ b/TaxPayerFull/Layout/ItemBlog.razor @@ -3,19 +3,19 @@
- +
- @Item.Title.Split(':')[0] + @Item?.Title.Split(':')[0]
- @Item.Date + @Item?.Date
diff --git a/TaxPayerFull/Layout/ItemQuestion.razor b/TaxPayerFull/Layout/ItemQuestion.razor new file mode 100644 index 0000000..fbb39a2 --- /dev/null +++ b/TaxPayerFull/Layout/ItemQuestion.razor @@ -0,0 +1,20 @@ +@using Shared.DTOs + +
+

+ +

+
+
+ @item.Answer +
+
+
+ +@code { + [Parameter] + public QuestionDto? item { get; set; } +} diff --git a/TaxPayerFull/Layout/LQuestion.razor b/TaxPayerFull/Layout/LQuestion.razor new file mode 100644 index 0000000..858e525 --- /dev/null +++ b/TaxPayerFull/Layout/LQuestion.razor @@ -0,0 +1,70 @@ +@using Shared.DTOs +@inject HttpClient _hc +@inject NavigationManager Navigation +
+
+
+
+

سوالات پر تکرار

+
+
+ + @foreach (var item in request?.list) + { + + } + @* *@ +
+
+
+
+ +
+
+ +@code { + [Parameter, SupplyParameterFromQuery] + public int? PageIndex { get; set; } + + QuestionDto modeltest = new QuestionDto + { + Answer = "ندارد", + Category = "تست", + ID = 1, + Title = "دسته" + }; + + public Shared.DTOs.PagingDto? request { get; set; } = new PagingDto(1, 1, new List() + { + new QuestionDto + { + Answer="ندارد",Category="تست",ID=1,Title="دسته" + } + }); + + // protected override async Task OnParametersSetAsync() + // { + // if (PageIndex == null) PageIndex = 1; + // request = await _hc.GetFromJsonAsync>($"Base/LastQuestion?PageIndex={PageIndex ?? 1}&PageSize=6"); + // await base.OnParametersSetAsync(); + // } +} diff --git a/TaxPayerFull/Pages/Home.razor b/TaxPayerFull/Pages/Home.razor index f47271a..3a78c2a 100644 --- a/TaxPayerFull/Pages/Home.razor +++ b/TaxPayerFull/Pages/Home.razor @@ -374,6 +374,9 @@ + + +