models
This commit is contained in:
65
Back/Services/Warehouse/WarehouseService.cs
Normal file
65
Back/Services/Warehouse/WarehouseService.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models.Warehouse;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.OpenApi.Extensions;
|
||||
using Shared.DTOs.Warehouse;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Back.Services.Warehouse
|
||||
{
|
||||
public class WarehouseService
|
||||
{
|
||||
private readonly IAsyncRepository<Remittance> _RemittanceRepo;
|
||||
private readonly IAsyncRepository<Receipt> _ReceiptRepo;
|
||||
|
||||
public WarehouseService(IAsyncRepository<Remittance> remittanceRepo, IAsyncRepository<Receipt> receiptRepo)
|
||||
{
|
||||
_RemittanceRepo = remittanceRepo;
|
||||
_ReceiptRepo = receiptRepo;
|
||||
}
|
||||
public async Task<List<CirculationDto>> Circulation(int CompanyID,string date="",int CODID=0)
|
||||
{
|
||||
var RequestRemittance = _RemittanceRepo.Get(w => w.cODItem.CompanyID == CompanyID)
|
||||
.Select(s=>new CirculationDto
|
||||
{
|
||||
CODID=s.CODID,
|
||||
CODTitle=s.cODItem.Title,
|
||||
Date=s.Date,
|
||||
Count=s.Count,
|
||||
info=s.info,
|
||||
Type=TypeCirculation.Remittance,
|
||||
ModelTypeID = (int)s.Type,
|
||||
ModelTypeTitle= s.Type.GetDisplayName()
|
||||
});
|
||||
if (!string.IsNullOrEmpty(date))
|
||||
RequestRemittance = RequestRemittance.Where(w => w.Date == date);
|
||||
if (CODID!=0)
|
||||
RequestRemittance = RequestRemittance.Where(w => w.CODID == CODID);
|
||||
//-----------
|
||||
var RequestReceipt = _ReceiptRepo.Get(w => w.cODItem.CompanyID == CompanyID)
|
||||
.Select(s => new CirculationDto
|
||||
{
|
||||
CODID = s.CODID,
|
||||
CODTitle = s.cODItem.Title,
|
||||
Date = s.Date,
|
||||
Count = s.Count,
|
||||
info = s.info,
|
||||
Type = TypeCirculation.Receipt,
|
||||
ModelTypeID = (int)s.Type,
|
||||
ModelTypeTitle = s.Type.GetDisplayName()
|
||||
});
|
||||
if (!string.IsNullOrEmpty(date))
|
||||
RequestReceipt = RequestReceipt.Where(w => w.Date == date);
|
||||
if (CODID != 0)
|
||||
RequestReceipt = RequestReceipt.Where(w => w.CODID == CODID);
|
||||
|
||||
var list = await RequestReceipt.ToListAsync();
|
||||
list.AddRange(await RequestRemittance.ToListAsync());
|
||||
return list.OrderByDescending(o=>o.Date).ToList();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user