Files
moadiran/Back/Services/servInvoicePayment.cs

57 lines
2.0 KiB
C#
Raw Normal View History

2024-08-28 00:29:35 +03:30
using Back.Data.Contracts;
using Back.Data.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Hosting;
using Shared.DTOs;
namespace Back.Services
{
public class servInvoicePayment
{
private readonly IAsyncRepository<InvoicePayment> _Repo;
2024-09-08 17:23:33 +03:30
private readonly IAsyncRepository<Coding> _CodingRepo;
public servInvoicePayment(IAsyncRepository<InvoicePayment> Repo, IAsyncRepository<Coding> CodingRepo)
2024-08-28 00:29:35 +03:30
{
_Repo = Repo;
2024-09-08 17:23:33 +03:30
_CodingRepo = CodingRepo;
2024-08-28 00:29:35 +03:30
}
2024-09-08 17:23:33 +03:30
public async Task<InvoicePayment> Add(InvoicePayment item)
2024-08-28 00:29:35 +03:30
{
2024-09-08 17:23:33 +03:30
return await _Repo.AddAsync(item);
2024-08-28 00:29:35 +03:30
}
2024-09-08 17:23:33 +03:30
public async Task<InvoicePayment> Update(InvoicePayment item)
2024-08-28 00:29:35 +03:30
{
2024-09-08 17:23:33 +03:30
return await _Repo.UpdateByObjAsync(item);
2024-08-28 00:29:35 +03:30
}
public async Task<bool> Delete(InvoicePayment item)
{
return await _Repo.DeleteAsync(item);
}
public async Task<bool> Exist(int companyID, int invoiceID, int ID)
{
return await _Repo.Get(w => w.InvoiceID == invoiceID && w.ID == ID && w.invoice.CompanyID == companyID).AnyAsync();
}
public async Task<InvoicePayment?> GetinvoicePay(int CompanyID, int ID)
{
return await _Repo
.Get(w => w.ID == ID && w.invoice.CompanyID == CompanyID && !w.invoice.IsDeleted)
.Include(s=>s.invoice)
.FirstOrDefaultAsync();
}
public async Task<InvoicePayment> GetInvoicePayByInvoicePayID (int companyID, int invoiceID, int ID)
{
return await _Repo.Get(w => w.InvoiceID == invoiceID && w.ID == ID && w.invoice.CompanyID == companyID).FirstOrDefaultAsync();
}
2024-09-08 17:23:33 +03:30
public async Task<List<IdName<string>>> GetPaymentMethods()
{
return await _CodingRepo.Get(w => w.FildID == 71)
.Select(s=>new IdName<string>
{
ID=s.Code,Title=s.Title
}).ToListAsync();
}
2024-08-28 00:29:35 +03:30
}
}