55 lines
2.0 KiB
C#
55 lines
2.0 KiB
C#
using CPRNIMS.Domain.Contracts.Finance;
|
|
using CPRNIMS.Infrastructure.Database;
|
|
using CPRNIMS.Infrastructure.Dto.Finance;
|
|
using CPRNIMS.Infrastructure.Entities.Finance;
|
|
using CPRNIMS.Infrastructure.Entities.Purchasing;
|
|
using Microsoft.Data.SqlClient;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CPRNIMS.Domain.Services.Finance
|
|
{
|
|
public class RR : IRR
|
|
{
|
|
private readonly NonInventoryDbContext _dbContext;
|
|
public RR(NonInventoryDbContext dbContext)
|
|
{
|
|
_dbContext = dbContext;
|
|
}
|
|
public async Task<List<ForPayment>> GetAllClosedPO(RRDetailsDto itemDto)
|
|
{
|
|
var allItems = await _dbContext.ForPayments
|
|
.FromSqlRaw($"EXEC GetAllClosedPO @UserId = '{itemDto.UserId}'")
|
|
.ToListAsync();
|
|
|
|
return allItems ?? new List<ForPayment>();
|
|
}
|
|
public async Task<List<ReceivingDetail>> GetRRDetailByPO(RRDetailsDto itemDto)
|
|
{
|
|
var allItems = await _dbContext.ReceivingDetails
|
|
.FromSqlRaw($"EXEC GetRRDetailByPOFinance @PONo,@POTypeId,@UserId",
|
|
new SqlParameter("@PONo", itemDto.PONo),
|
|
new SqlParameter("@POTypeId", itemDto.POTypeId),
|
|
new SqlParameter("@UserId", itemDto.UserId))
|
|
.ToListAsync();
|
|
|
|
return allItems ?? new List<ReceivingDetail>();
|
|
}
|
|
|
|
public async Task<RRDetail> PostPutPayment(RRDetailsDto itemDto)
|
|
{
|
|
await _dbContext.Database
|
|
.ExecuteSqlRawAsync("EXEC PostPutPayment @UserId, @PONo, @POTypeId, @PRDetailsId",
|
|
new SqlParameter("@UserId", itemDto.UserId),
|
|
new SqlParameter("@PONo", itemDto.PONo),
|
|
new SqlParameter("@POTypeId", itemDto.POTypeId),
|
|
new SqlParameter("@PRDetailsId", itemDto.PRDetailsId));
|
|
return new RRDetail();
|
|
}
|
|
}
|
|
}
|