46 lines
1.7 KiB
C#
46 lines
1.7 KiB
C#
using Back.Data.Contracts;
|
|
using Back.Data.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Shared.DTOs;
|
|
|
|
namespace Back.Services
|
|
{
|
|
public class servInvoiceItem
|
|
{
|
|
private readonly IAsyncRepository<InvoiceItem> _invoiceitemRepo;
|
|
public servInvoiceItem(IAsyncRepository<InvoiceItem> invoiceitemRepo)
|
|
{
|
|
_invoiceitemRepo = invoiceitemRepo;
|
|
}
|
|
public async Task<bool> Add(InvoiceItem item)
|
|
{
|
|
return await _invoiceitemRepo.AddBoolResultAsync(item);
|
|
}
|
|
public async Task<bool> Update(InvoiceItem item)
|
|
{
|
|
return await _invoiceitemRepo.UpdateAsync(item);
|
|
}
|
|
public async Task<bool> Delete(InvoiceItem item)
|
|
{
|
|
return await _invoiceitemRepo.DeleteAsync(item);
|
|
}
|
|
public async Task<bool> Exist(int companyID,int invoiceID,int invoiceitemID)
|
|
{
|
|
return await _invoiceitemRepo.Get(w => w.InvoiceID == invoiceID && w.ID == invoiceitemID && w.invoice.CompanyID == companyID).AnyAsync();
|
|
}
|
|
public async Task<InvoiceItem?> GetInvoiceItemByInvoiceItemID(int CompanyID, int InvoiceItemID)
|
|
{
|
|
return await _invoiceitemRepo
|
|
.Get(w => w.ID == InvoiceItemID && w.invoice.CompanyID == CompanyID && !w.invoice.IsDeleted)
|
|
.Include(s=>s.invoice)
|
|
.FirstOrDefaultAsync();
|
|
}
|
|
public async Task<InvoiceItem> Getinvoiceitem(int companyID, int invoiceID, int invoiceitemID)
|
|
{
|
|
return await _invoiceitemRepo.Get(w => w.InvoiceID == invoiceID && w.ID == invoiceitemID && w.invoice.CompanyID == companyID).FirstOrDefaultAsync();
|
|
}
|
|
|
|
}
|
|
}
|