Tag in blog
This commit is contained in:
@@ -48,8 +48,8 @@ namespace Back.Controllers
|
|||||||
public async Task<ActionResult<DateTime>> DateTimeServer()
|
public async Task<ActionResult<DateTime>> DateTimeServer()
|
||||||
=> Ok(DateTime.Now);
|
=> Ok(DateTime.Now);
|
||||||
[HttpGet("LastBlog")]
|
[HttpGet("LastBlog")]
|
||||||
public async Task<ActionResult<PagingDto<BlogDto>>> LastBlog(int PageIndex, int PageSize)
|
public async Task<ActionResult<PagingDto<BlogDto>>> LastBlog(int PageIndex, int PageSize,string? Tag)
|
||||||
=> Ok(await _sBase.GetBlog(PageIndex, PageSize));
|
=> Ok(await _sBase.GetBlog(PageIndex, PageSize,Tag));
|
||||||
[HttpGet("GetBlogByID/{ID}")]
|
[HttpGet("GetBlogByID/{ID}")]
|
||||||
public async Task<ActionResult<BlogDtoFull?>> GetBlogByID(int ID)
|
public async Task<ActionResult<BlogDtoFull?>> GetBlogByID(int ID)
|
||||||
{
|
{
|
||||||
|
@@ -9,5 +9,6 @@
|
|||||||
public string Date { get; set; }
|
public string Date { get; set; }
|
||||||
public string Time { get; set; }
|
public string Time { get; set; }
|
||||||
public bool Status { 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.Contracts;
|
||||||
using Back.Data.Models;
|
using Back.Data.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@@ -37,9 +38,13 @@ namespace Back.Services
|
|||||||
PermissionID=x.PermissionID,
|
PermissionID=x.PermissionID,
|
||||||
}).ToListAsync();
|
}).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
|
.Select(s=>new BlogDto
|
||||||
{
|
{
|
||||||
Title = s.Title,
|
Title = s.Title,
|
||||||
@@ -70,7 +75,8 @@ namespace Back.Services
|
|||||||
ID = s.ID,
|
ID = s.ID,
|
||||||
Photo = string.IsNullOrEmpty(s.Photo) ? "blog-SampleTitle.jpg" : s.Photo,
|
Photo = string.IsNullOrEmpty(s.Photo) ? "blog-SampleTitle.jpg" : s.Photo,
|
||||||
Text=s.Text,
|
Text=s.Text,
|
||||||
Time=s.Time
|
Time=s.Time,
|
||||||
|
Tags= s.Tags,
|
||||||
}).FirstOrDefaultAsync();
|
}).FirstOrDefaultAsync();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -21,5 +21,6 @@ namespace Shared.DTOs
|
|||||||
public string? Photo { get; set; }
|
public string? Photo { get; set; }
|
||||||
public string Date { 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>
|
</a>
|
||||||
</div><a href="blog-details.html">
|
</div><a href="blog-details.html">
|
||||||
</a>
|
</a>
|
||||||
</div><a href="blog-details.html">
|
</div>
|
||||||
</a>
|
|
||||||
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user