* Removed not needed code

* Changed string parameters to GUID
This commit is contained in:
2025-02-01 07:21:57 +01:00
parent 98777328d7
commit 51f5c09d82
4 changed files with 15 additions and 19 deletions

View File

@@ -79,9 +79,13 @@ namespace SytelineSaAppEfDataModel.Services
return ediCustomerOrder;
}
public async Task<int> SendOrderToSyteline(string customerOrderNumber)
public async Task<int> SendOrderToSyteline(Guid customerOrderNumber)
{
var ediCoNum = new SqlParameter("@PEdiCoNum", SqlDbType.NVarChar, 50) { Value = customerOrderNumber };
EdiCustomerOrder? ediCustomerOrder = await context.EdiCustomerOrders.FirstOrDefaultAsync(x => x.RowPointer == customerOrderNumber);
if (ediCustomerOrder == null) return 0;
var ediCoNum = new SqlParameter("@PEdiCoNum", SqlDbType.NVarChar, 50) { Value = ediCustomerOrder.CustomerOrderNumber };
var ediCoCount = new SqlParameter("@PEdiCoCount", SqlDbType.Int) { Value = 0, Direction = ParameterDirection.Output };
var postedCount = new SqlParameter("@PPostedCount", SqlDbType.Int) { Value = 0, Direction = ParameterDirection.Output };
var infoBar = new SqlParameter("@Infobar", SqlDbType.NVarChar, 2800) { Value = "", Direction = ParameterDirection.Output };
@@ -92,10 +96,6 @@ namespace SytelineSaAppEfDataModel.Services
"EXEC [dbo].[FKR_EDI_EXTGEN_EdiInOrderPSp] @PEdiCoNum, @PEdiCoCount OUT, @PPostedCount OUT, @Infobar OUT, @AutoPost, @ProcessId",
ediCoNum, ediCoCount, postedCount, infoBar, autoPost, processId);
//var result = await context.Database.ExecuteSqlRawAsync(
// "EXEC [dbo].[FKR_EDI_EXTGEN_EdiInOrderPSp] @PEdiCoNum, @PEdiCoCount, @PPostedCount, @Infobar, @AutoPost, @ProcessId",
// parameter1, parameter2, parameter3, parameter4, parameter5, parameter6);
string? infoBarResult = infoBar.Value?.ToString();
int ediCoCountResult = Convert.ToInt32(ediCoCount.Value);
int postedCountResult = Convert.ToInt32(postedCount.Value);
@@ -105,10 +105,6 @@ namespace SytelineSaAppEfDataModel.Services
Console.WriteLine($"Posted Count: {postedCountResult}");
return postedCountResult;
//// Jeśli chcesz pobrać wyniki procedury składowanej:
//var results = context.SomeEntity.FromSqlRaw(
// "EXEC YourStoredProcedure @Param1, @Param2",
// parameter1, parameter2).ToList();
}
}
}

View File

@@ -1,10 +1,5 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SytelineSaAppEfDataModel.Dtos;
namespace SytelineSaAppEfDataModel.Services
@@ -18,8 +13,13 @@ namespace SytelineSaAppEfDataModel.Services
public async Task<IEnumerable<ErrorLogDto>> GetByOrderNumber(Guid customerOrderNumber)
{
return await context.ErrorLogs.Where(x => x.TrxNum == customerOrderNumber)
EdiCustomerOrderDto ediCustomerOrderDto = mapper.Map<EdiCustomerOrderDto>(
await context.EdiCustomerOrders.FirstOrDefaultAsync(x => x.RowPointer.Equals(customerOrderNumber)));
if (ediCustomerOrderDto == null) return [];
return await context.ErrorLogs.Where(x => x.TrxNum == ediCustomerOrderDto.CustomerOrderNumber)
.Select(x => mapper.Map<ErrorLogDto>(x)).ToListAsync();
}
}
}
}

View File

@@ -12,6 +12,6 @@ namespace SytelineSaAppEfDataModel.Services
Task<IEnumerable<EdiCustomerOrderDto>> GetAll();
Task<IEnumerable<EdiCustomerOrderDto?>> GetByDate(DateTime date);
Task<EdiCustomerOrderDto?> GetByOrderNumber(Guid orderNumber);
Task<int> SendOrderToSyteline(string customerOrderNumber);
Task<int> SendOrderToSyteline(Guid customerOrderNumber);
}
}