order
This commit is contained in:
41
Back/Services/ServPromotion.cs
Normal file
41
Back/Services/ServPromotion.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shared.DTOs;
|
||||
|
||||
namespace Back.Services
|
||||
{
|
||||
|
||||
|
||||
public class ServPromotion
|
||||
{
|
||||
private readonly IAsyncRepository<Promotion> _repoPromotion;
|
||||
private readonly IAsyncRepository<PromotionDetails> _repoPromotionDetails;
|
||||
|
||||
|
||||
public ServPromotion(IAsyncRepository<Promotion> repoPromotion, IAsyncRepository<PromotionDetails> repoPromotionDetails)
|
||||
{
|
||||
_repoPromotion = repoPromotion;
|
||||
_repoPromotionDetails = repoPromotionDetails;
|
||||
|
||||
}
|
||||
public async Task<List<PromotionDto>> GetAll()
|
||||
{
|
||||
return await _repoPromotion.Get(w => w.Status)
|
||||
.Include(inc => inc.PromotionDetails).ThenInclude(tinc => tinc.Permission)
|
||||
.Select(s => new PromotionDto
|
||||
{
|
||||
ID = s.ID,
|
||||
Name = s.Name,
|
||||
promotionDetails = s.PromotionDetails.Select(s => new PromotionDetailDto
|
||||
{
|
||||
ID = s.ID,
|
||||
APrice = s.APrice,
|
||||
CreditAmount = s.CreditAmount,
|
||||
PermissionID = s.PermissionID,
|
||||
PermissionTitle = s.Permission.Title
|
||||
}).ToList()
|
||||
}).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user