* Removed not needed code
* Changed string parameters to GUID
This commit is contained in:
@@ -30,7 +30,7 @@ namespace FaKrosnoApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("send-to-syteline")]
|
[HttpPost("send-to-syteline")]
|
||||||
public async Task<ActionResult<int>> SendOrderToSyteline([FromQuery] string customerOrderNumber)
|
public async Task<ActionResult<int>> SendOrderToSyteline([FromQuery] Guid customerOrderNumber)
|
||||||
{
|
{
|
||||||
int result = await service.SendOrderToSyteline(customerOrderNumber);
|
int result = await service.SendOrderToSyteline(customerOrderNumber);
|
||||||
return result > 0 ? Ok() : BadRequest();
|
return result > 0 ? Ok() : BadRequest();
|
||||||
|
|||||||
@@ -79,9 +79,13 @@ namespace SytelineSaAppEfDataModel.Services
|
|||||||
return ediCustomerOrder;
|
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 ediCoCount = new SqlParameter("@PEdiCoCount", SqlDbType.Int) { Value = 0, Direction = ParameterDirection.Output };
|
||||||
var postedCount = new SqlParameter("@PPostedCount", 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 };
|
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",
|
"EXEC [dbo].[FKR_EDI_EXTGEN_EdiInOrderPSp] @PEdiCoNum, @PEdiCoCount OUT, @PPostedCount OUT, @Infobar OUT, @AutoPost, @ProcessId",
|
||||||
ediCoNum, ediCoCount, postedCount, infoBar, 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();
|
string? infoBarResult = infoBar.Value?.ToString();
|
||||||
int ediCoCountResult = Convert.ToInt32(ediCoCount.Value);
|
int ediCoCountResult = Convert.ToInt32(ediCoCount.Value);
|
||||||
int postedCountResult = Convert.ToInt32(postedCount.Value);
|
int postedCountResult = Convert.ToInt32(postedCount.Value);
|
||||||
@@ -105,10 +105,6 @@ namespace SytelineSaAppEfDataModel.Services
|
|||||||
Console.WriteLine($"Posted Count: {postedCountResult}");
|
Console.WriteLine($"Posted Count: {postedCountResult}");
|
||||||
|
|
||||||
return postedCountResult;
|
return postedCountResult;
|
||||||
//// Jeśli chcesz pobrać wyniki procedury składowanej:
|
|
||||||
//var results = context.SomeEntity.FromSqlRaw(
|
|
||||||
// "EXEC YourStoredProcedure @Param1, @Param2",
|
|
||||||
// parameter1, parameter2).ToList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using SytelineSaAppEfDataModel.Dtos;
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
|
||||||
namespace SytelineSaAppEfDataModel.Services
|
namespace SytelineSaAppEfDataModel.Services
|
||||||
@@ -18,8 +13,13 @@ namespace SytelineSaAppEfDataModel.Services
|
|||||||
|
|
||||||
public async Task<IEnumerable<ErrorLogDto>> GetByOrderNumber(Guid customerOrderNumber)
|
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();
|
.Select(x => mapper.Map<ErrorLogDto>(x)).ToListAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,6 @@ namespace SytelineSaAppEfDataModel.Services
|
|||||||
Task<IEnumerable<EdiCustomerOrderDto>> GetAll();
|
Task<IEnumerable<EdiCustomerOrderDto>> GetAll();
|
||||||
Task<IEnumerable<EdiCustomerOrderDto?>> GetByDate(DateTime date);
|
Task<IEnumerable<EdiCustomerOrderDto?>> GetByDate(DateTime date);
|
||||||
Task<EdiCustomerOrderDto?> GetByOrderNumber(Guid orderNumber);
|
Task<EdiCustomerOrderDto?> GetByOrderNumber(Guid orderNumber);
|
||||||
Task<int> SendOrderToSyteline(string customerOrderNumber);
|
Task<int> SendOrderToSyteline(Guid customerOrderNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user