order
This commit is contained in:
62
Back/Services/ServOrders.cs
Normal file
62
Back/Services/ServOrders.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shared.DTOs;
|
||||
using Shared.DTOs.Serch;
|
||||
|
||||
namespace Back.Services
|
||||
{
|
||||
public class ServOrders
|
||||
{
|
||||
private readonly IAsyncRepository<Order> _repoOrder;
|
||||
private readonly IAsyncRepository<OrderItem> _repoOrderItem;
|
||||
|
||||
|
||||
public ServOrders(IAsyncRepository<Order> repoOrder, IAsyncRepository<OrderItem> repoOrderItem)
|
||||
{
|
||||
_repoOrder = repoOrder;
|
||||
_repoOrderItem = repoOrderItem;
|
||||
|
||||
}
|
||||
public async Task<List<OrderDto>> GetOrdersByCompanyID(int CompanyID, ItemSerachOrder itemSerach)
|
||||
{
|
||||
var request = _repoOrder.Get(w => w.CompanyID == CompanyID);
|
||||
|
||||
if (itemSerach.Status.HasValue)
|
||||
request = request.Where(w => w.Status == itemSerach.Status);
|
||||
|
||||
if (itemSerach.ID.HasValue)
|
||||
request = request.Where(w => w.ID == itemSerach.ID);
|
||||
|
||||
request = request.Include(inc => inc.OrderItems);
|
||||
return await request
|
||||
.Select(w => new OrderDto
|
||||
{
|
||||
ApprovalDate = w.ApprovalDate,
|
||||
DateCreate = w.DateCreate,
|
||||
ID = w.ID,
|
||||
PreDiscount = w.PreDiscount,
|
||||
Status = w.Status,
|
||||
TDiscount = w.TDiscount,
|
||||
TPrice = w.TPrice,
|
||||
TTax = w.TPrice,
|
||||
lstDiscount = w.lstDiscount,
|
||||
}).ToListAsync();
|
||||
}
|
||||
public async Task<List<OrderItemDto>> GetOrderItems(int OrderID,int CompanyID)
|
||||
{
|
||||
return await _repoOrderItem.Get(w => w.OrderID == OrderID && w.Order.CompanyID== CompanyID)
|
||||
.Select(s=>new OrderItemDto
|
||||
{
|
||||
OrderID = OrderID,
|
||||
APrice = s.APrice,
|
||||
CreditAmount = s.CreditAmount,
|
||||
Discount=s.Discount,
|
||||
ID = s.ID,
|
||||
Tax = s.Tax,
|
||||
Type= s.PermissionID.HasValue && !s.PromotionID.HasValue ? "" : !s.PermissionID.HasValue && s.PromotionID.HasValue ? "تعرفه" : "نامشخص",
|
||||
IDForType = s.PermissionID.HasValue && !s.PromotionID.HasValue ? s.PermissionID.Value : !s.PermissionID.HasValue && s.PromotionID.HasValue ? s.PromotionID.Value : 0
|
||||
}).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
28
Back/Services/ServPricing.cs
Normal file
28
Back/Services/ServPricing.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shared.DTOs;
|
||||
|
||||
namespace Back.Services
|
||||
{
|
||||
|
||||
public class ServPricing
|
||||
{
|
||||
private readonly IAsyncRepository<Pricing> _repoPricing;
|
||||
|
||||
public ServPricing(IAsyncRepository<Pricing> repoPricing)
|
||||
{
|
||||
_repoPricing = repoPricing;
|
||||
}
|
||||
public async Task<List<PricingDto>> GetPricing()
|
||||
{
|
||||
return await _repoPricing.GetAll()
|
||||
.Select(s=>new PricingDto
|
||||
{
|
||||
PermissionID = s.PermissionID,
|
||||
PermissionTitle=s.Permission.Title,
|
||||
Price = s.Price,
|
||||
}).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
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