* Extended of Dtos

* Added new Services and Controllers
This commit is contained in:
2025-09-03 15:04:22 +02:00
parent 47f37d016d
commit 0199467f72
15 changed files with 172 additions and 23 deletions

View File

@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using SytelineSaAppEfDataModel.Dtos;
using SytelineSaAppEfDataModel.Services;
namespace FaKrosnoApi.Controllers;
@@ -13,4 +14,22 @@ public class EdiCustomerOrderImportController(IEdiCustomerOrderImportService ser
DateTime lastUpdateDate = await service.GetLastUpdateDate();
return Ok(lastUpdateDate);
}
[HttpPost]
public async Task<ActionResult> Add([FromBody] EdiCustomerOrderImportDto ediCustomerOrderImport)
{
var result = await service.AddEdiCustomerOrderImport(ediCustomerOrderImport);
return result
? Ok("Utworzono rekord w tabeli EdiCustomerOrderImport.")
: BadRequest($"Nie mogę utworzyć rekordu w tabeli EdiCustomerOrderImport.");
}
[HttpPost("add-bulk")]
public async Task<ActionResult> Add([FromBody] IList<EdiCustomerOrderImportDto> ediCustomerOrderImports)
{
var result = await service.AddEdiCustomerOrderImports(ediCustomerOrderImports);
return result
? Ok("Utworzono rekordy w tabeli EdiCustomerOrderImport.")
: BadRequest($"Nie mogę utworzyć rekordów w tabeli EdiCustomerOrderImport.");
}
}

View File

@@ -55,7 +55,7 @@ namespace FaKrosnoApi.Controllers
var result = await service.SaveOrdersWithDetails(ediCustomerOrders);
return result.Item1
? Ok("Orders saved successfully.")
? Ok(result)
: BadRequest($"Failed to save orders. Error: {result.Item2}");
}
}

View File

@@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Mvc;
using SytelineSaAppEfDataModel.Dtos;
using SytelineSaAppEfDataModel.Services;
namespace FaKrosnoApi.Controllers;
[ApiController]
[Route("api/[controller]")]
public class EdiLogController(IEdiLogService service) : Controller
{
[HttpPost]
public async Task<ActionResult> Add([FromBody] EdiLogDto ediLog)
{
var result = await service.AddEdiLog(ediLog);
return result
? Ok("Utworzono rekord w tabeli EdiLog.")
: BadRequest($"Nie mogę utworzyć rekordu w tabeli EdiLog.");
}
}

View File

@@ -66,19 +66,19 @@ builder.Services.AddOpenApiDocument(config =>
config.OperationProcessors.Add(new OperationSecurityScopeProcessor("Bearer"));
});
// builder.Services.AddHangfire(config => config
// .SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
// .UseSimpleAssemblyNameTypeSerializer()
// .UseRecommendedSerializerSettings()
// .UseSqlServerStorage(builder.Configuration.GetConnectionString("OrdersManagementConnection"), new SqlServerStorageOptions
// {
// CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
// SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
// QueuePollInterval = TimeSpan.Zero,
// UseRecommendedIsolationLevel = true,
// DisableGlobalLocks = true
// }));
// builder.Services.AddHangfireServer();
builder.Services.AddHangfire(config => config
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseSqlServerStorage(builder.Configuration.GetConnectionString("OrdersManagementConnection"), new SqlServerStorageOptions
{
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
QueuePollInterval = TimeSpan.Zero,
UseRecommendedIsolationLevel = true,
DisableGlobalLocks = true
}));
builder.Services.AddHangfireServer();
builder.Services.AddAutoMapper(typeof(FaKrosnoMappingProfile), typeof(SytelineSaAppMappingProfile),
typeof(OrdersManagementMappingProfile));
@@ -108,6 +108,7 @@ builder.Services.AddScoped<ICustomerTpService, CustomerTpService>();
builder.Services.AddScoped<IItemService, ItemService>();
builder.Services.AddScoped<IVatCodeAssociationService, VatCodeAssociationService>();
builder.Services.AddScoped<IItemCustPriceAllService, ItemCustPriceAllService>();
builder.Services.AddScoped<IEdiLogService, EdiLogService>();
builder.Services.AddHostedService<TimedHostedService>();
@@ -125,6 +126,6 @@ app.UseAuthorization();
app.MapControllers();
//app.UseHangfireDashboard();
app.UseHangfireDashboard();
app.Run();

View File

@@ -1,7 +1,7 @@
{
"ConnectionStrings": {
"FaKrosnoConnection": "Server=192.168.0.7;Database=fakrosno;User Id=sa;Password=Tetum#2021!;TrustServerCertificate=true",
"SytelineSaAppConnection": "Server=192.168.0.7;Database=SL_PROD_SA_APP;User Id=sa;Password=Tetum#2021!;TrustServerCertificate=true",
"SytelineSaAppConnection": "Server=192.168.0.7;Database=SL_PRODTEST_SA_APP;User Id=sa;Password=Tetum#2021!;TrustServerCertificate=true",
"OrdersManagementConnection": "Server=192.168.0.7;Database=OrdersManagement;User Id=sa;Password=Tetum#2021!;TrustServerCertificate=true"
},
"Logging": {