Tag in blog
This commit is contained in:
@@ -48,8 +48,8 @@ namespace Back.Controllers
|
||||
public async Task<ActionResult<DateTime>> DateTimeServer()
|
||||
=> Ok(DateTime.Now);
|
||||
[HttpGet("LastBlog")]
|
||||
public async Task<ActionResult<PagingDto<BlogDto>>> LastBlog(int PageIndex, int PageSize)
|
||||
=> Ok(await _sBase.GetBlog(PageIndex, PageSize));
|
||||
public async Task<ActionResult<PagingDto<BlogDto>>> LastBlog(int PageIndex, int PageSize,string? Tag)
|
||||
=> Ok(await _sBase.GetBlog(PageIndex, PageSize,Tag));
|
||||
[HttpGet("GetBlogByID/{ID}")]
|
||||
public async Task<ActionResult<BlogDtoFull?>> GetBlogByID(int ID)
|
||||
{
|
||||
|
@@ -9,5 +9,6 @@
|
||||
public string Date { get; set; }
|
||||
public string Time { get; set; }
|
||||
public bool Status { get; set; }
|
||||
public string? Tags { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using Back.Common;
|
||||
using Azure;
|
||||
using Back.Common;
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -37,9 +38,13 @@ namespace Back.Services
|
||||
PermissionID=x.PermissionID,
|
||||
}).ToListAsync();
|
||||
}
|
||||
public async Task<PagingDto<BlogDto>> GetBlog(int PageIndex, int PageSize)
|
||||
public async Task<PagingDto<BlogDto>> GetBlog(int PageIndex, int PageSize,string? Tag)
|
||||
{
|
||||
return await _repoBlog.Get(w=>w.Status).OrderByDescending(o=>o.ID)
|
||||
var request = _repoBlog.Get(w => w.Status);
|
||||
if (!string.IsNullOrEmpty(Tag))
|
||||
request = request.Where(x => x.Tags.Contains(Tag));
|
||||
|
||||
return await request.OrderByDescending(o=>o.ID)
|
||||
.Select(s=>new BlogDto
|
||||
{
|
||||
Title = s.Title,
|
||||
@@ -70,7 +75,8 @@ namespace Back.Services
|
||||
ID = s.ID,
|
||||
Photo = string.IsNullOrEmpty(s.Photo) ? "blog-SampleTitle.jpg" : s.Photo,
|
||||
Text=s.Text,
|
||||
Time=s.Time
|
||||
Time=s.Time,
|
||||
Tags= s.Tags,
|
||||
}).FirstOrDefaultAsync();
|
||||
return result;
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ namespace Shared.DTOs
|
||||
public string Text { get; set; }
|
||||
public string? Photo { get; set; }
|
||||
public string Date { get; set; }
|
||||
public string Time { get; set; }
|
||||
public string Time { get; set; }
|
||||
public string? Tags { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -99,8 +99,24 @@
|
||||
</a>
|
||||
</div><a href="blog-details.html">
|
||||
</a>
|
||||
</div><a href="blog-details.html">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="sidebar__widget mb-40">
|
||||
<div class="sidebar__widge-title-box">
|
||||
<h3 class="sidebar__widget-title">برچسب ها</h3>
|
||||
</div>
|
||||
<div class="sidebar__widget-content">
|
||||
<div class="tagcloud">
|
||||
@foreach (var item in Item.Tags.Split(','))
|
||||
{
|
||||
<a href="#">@item</a>
|
||||
}
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user