This commit is contained in:
mmrbnjd
2024-04-03 14:36:33 +03:30
parent dd4969f504
commit 8e8bffa8a8
10 changed files with 109 additions and 85 deletions

View File

@@ -23,6 +23,14 @@ namespace Back.Controllers
[HttpGet("LastBlog")]
public async Task<ActionResult<PagingDto<BlogDto>>> LastBlog(int PageIndex,int PageSize)
=> Ok(await _sBase.GetBlog(PageIndex,PageSize));
[HttpGet("GetBlogByID/{ID}")]
public async Task<ActionResult<BlogDtoFull?>> GetBlogByID(int ID)
{
var result = await _sBase.GetBlogByID(ID);
if (result == null)
return NotFound();
return Ok(result);
}
}
}

View File

@@ -34,10 +34,23 @@ namespace Back.Services
Title = s.Title,
Date=s.Date,
ID=s.ID,
Photo=string.IsNullOrEmpty(s.Photo) ? "blog-grid-1.jpg" : s.Photo
Photo=string.IsNullOrEmpty(s.Photo) ? "blog-SampleTitle.jpg" : s.Photo
}).Paging(PageIndex, PageSize); ;
}
public async Task<BlogDtoFull?> GetBlogByID(int ID)
{
var result= await _repoBlog.Get(w => w.Status && w.ID==ID)
.Select(s => new BlogDtoFull
{
Title = s.Title,
Date = s.Date,
ID = s.ID,
Photo = string.IsNullOrEmpty(s.Photo) ? "blog-SampleTitle.jpg" : s.Photo,
Text=s.Text,
Time=s.Time
}).FirstOrDefaultAsync();
return result;
}
}
}