...
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Common\DTOs\" />
|
||||
<Folder Include="Features\" />
|
||||
<Folder Include="Validations\" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
namespace Back.Common.ViewModels
|
||||
{
|
||||
public class PagingDto<T>
|
||||
{
|
||||
public PagingDto(int RowCount, int pageCount, List<T> list)
|
||||
{
|
||||
this.RowCount = RowCount;
|
||||
this.list = list;
|
||||
PageCount = pageCount;
|
||||
|
||||
}
|
||||
public int RowCount { get; set; }
|
||||
public int PageCount { get; set; }
|
||||
public List<T> list { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,8 @@ using System.Data;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using Back.Common.ViewModels;
|
||||
using Shared.DTOs;
|
||||
|
||||
|
||||
namespace Back.Common
|
||||
{
|
||||
|
||||
@@ -20,8 +20,9 @@ namespace Back.Controllers
|
||||
[HttpGet("DateTimeServer")]
|
||||
public async Task<ActionResult<DateTime>> DateTimeServer()
|
||||
=> Ok(DateTime.Now);
|
||||
[HttpGet("LastBlog/{Count}")]
|
||||
public async Task<ActionResult<List<BlogDto>>> LastBlog(int Count)
|
||||
=> Ok(await _sBase.GetBlog(Count));
|
||||
[HttpGet("LastBlog")]
|
||||
public async Task<ActionResult<PagingDto<BlogDto>>> LastBlog(int PageIndex,int PageSize)
|
||||
=> Ok(await _sBase.GetBlog(PageIndex,PageSize));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ builder.Services.AddCors(options =>
|
||||
options.AddPolicy(origins,
|
||||
policy =>
|
||||
{
|
||||
policy.WithOrigins("https://localhost:7224")
|
||||
policy.WithOrigins("https://localhost:7224", "http://localhost:5107")
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod();
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Common;
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shared.DTOs;
|
||||
@@ -25,17 +26,18 @@ namespace Back.Services
|
||||
PermissionID=x.PermissionID,
|
||||
}).ToListAsync();
|
||||
}
|
||||
public async Task<List<BlogDto>> GetBlog(int count)
|
||||
public async Task<PagingDto<BlogDto>> GetBlog(int PageIndex, int PageSize)
|
||||
{
|
||||
return await _repoBlog.Get(w=>w.Status).OrderByDescending(o=>o.ID).Take(count)
|
||||
return await _repoBlog.Get(w=>w.Status).OrderByDescending(o=>o.ID)
|
||||
.Select(s=>new BlogDto
|
||||
{
|
||||
Title = s.Title,
|
||||
Date=s.Date,
|
||||
ID=s.ID,
|
||||
Photo=string.IsNullOrEmpty(s.Photo) ? "blog-grid-1.jpg" : s.Photo
|
||||
})
|
||||
.ToListAsync();
|
||||
}).Paging(PageIndex, PageSize); ;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user