* Added managing EdiCustomerOrderTranslations

This commit is contained in:
2025-04-12 07:12:14 +02:00
parent 6977708099
commit 7660db1c0b
9 changed files with 185 additions and 3 deletions

View File

@@ -12,7 +12,7 @@
<main class="container-fluid d-flex flex-column h-100">
<div class="bb-top-row px-4 d-flex justify-content-between align-items-center mb-3 shadow-sm"
style="background-color: #f8f9fa;">
<div class="d-flex align-items-center">
<div class="d-flex align-items-center" style="margin: 10px">
<img src="logo.svg" class="me-2" width="35" height="35" alt="Icon">
<h3 class="text-primary m-0">FA Krosno Manager</h3>
</div>

View File

@@ -0,0 +1,96 @@
@page "/CustomerOrdersTranslations"
@using SytelineSaAppEfDataModel.Dtos
@using Syncfusion.Blazor.Cards
@using Syncfusion.Blazor.Grids
@using Action = Syncfusion.Blazor.Grids.Action
@inject EdiCustomerOrderTranslateService EdiCustomerOrderTranslateService
<div class="h-100 d-flex justify-content-center align-items-start">
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
<CardHeader>
<h3 class="text-primary">Zarządzanie powiązaniami zamówień z DELFORami</h3>
</CardHeader>
<CardContent>
<SfGrid DataSource="@OrderTranslations"
AllowFiltering="true"
AllowPaging="true"
AllowSorting="true"
AllowSelection="true"
EnableAdaptiveUI="true"
EnablePersistence="true"
AdaptiveUIMode="AdaptiveMode.Both"
Toolbar="@(new List<string> { "Edit", "Delete", "Cancel", "Update" })">
<GridColumns>
<GridColumn Field=@nameof(EdiCustomerOrderTranslateDto.Id) AllowEditing="false" IsPrimaryKey="true" Visible="false" HeaderText="Id"
Width="100"></GridColumn>
<GridColumn Field=@nameof(EdiCustomerOrderTranslateDto.ScheduleOrderId) HeaderText="DELFOR Id" Width="150"></GridColumn>
<GridColumn Field=@nameof(EdiCustomerOrderTranslateDto.EdiCoCoNum) HeaderText="Numer zamówienia EDI" Width="150"></GridColumn>
<GridColumn Field=@nameof(EdiCustomerOrderTranslateDto.CoCoNum) HeaderText="Numer zamówienia SL" Width="200"></GridColumn>
<GridColumn Field=@nameof(EdiCustomerOrderTranslateDto.CreatedDate) AllowEditing="false" HeaderText="Data utworzenia"
Width="150"></GridColumn>
</GridColumns>
<GridEditSettings AllowDeleting="true"
ShowDeleteConfirmDialog="true"
AllowEditing="true">
</GridEditSettings>
<GridEvents OnActionBegin="OnActionBegin"
OnActionComplete="OnActionComplete"
TValue="EdiCustomerOrderTranslateDto">
</GridEvents>
<GridPageSettings PageSize="10"></GridPageSettings>
<GridFilterSettings Type="FilterType.Excel"/>
</SfGrid>
</CardContent>
<CardFooter>
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
</CardFooter>
</SfCard>
</div>
@code {
private List<EdiCustomerOrderTranslateDto> OrderTranslations { get; set; } = new();
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
//
// if (currentUser.Identity?.IsAuthenticated == false || currentUser.Identity?.Name != "pkus")
// {
// NavigationManager.NavigateTo("/Unauthorized");
// }
// else
// {
await LoadTranslations();
StateHasChanged();
// }
}
}
public async Task OnActionBegin(ActionEventArgs<EdiCustomerOrderTranslateDto> args)
{
if (args.RequestType.Equals(Action.Delete))
{
await EdiCustomerOrderTranslateService.DeleteEdiCustomerOrderTranslateAsync(args.Data);
}
}
private async Task LoadTranslations()
{
OrderTranslations = (await EdiCustomerOrderTranslateService.GetEdiCustomerOrdersTranslationsAsync() ?? Array.Empty<EdiCustomerOrderTranslateDto>()).OrderByDescending(x => x.CreatedDate).ToList();
}
private async Task OnActionComplete(ActionEventArgs<EdiCustomerOrderTranslateDto> args)
{
switch (args.RequestType)
{
case Action.Delete:
await LoadTranslations();
break;
}
}
}

View File

@@ -44,6 +44,7 @@ builder.Services.AddRazorComponents()
builder.Services.AddScoped<ScheduleOrderService>();
builder.Services.AddScoped<EdiCustomerOrderService>();
builder.Services.AddScoped<EdiCustomerOrderTranslateService>();
builder.Services.AddScoped<CustomerOrderService>();
builder.Services.AddScoped<HangfireService>();
builder.Services.AddScoped<RoleService>();

View File

@@ -0,0 +1,29 @@
using SytelineSaAppEfDataModel.Dtos;
namespace OrdersManagement.Services;
public class EdiCustomerOrderTranslateService(
IHttpClientFactory httpClientFactory,
CustomAuthenticationStateProvider authenticationStateProvider)
: ServiceBase<EdiCustomerOrderTranslateDto>(httpClientFactory, authenticationStateProvider)
{
public async Task<IEnumerable<EdiCustomerOrderTranslateDto>?> GetEdiCustomerOrdersTranslationsAsync()
{
try
{
return await GetListAsync("api/EdiCustomerOrdersTranslations");
}
catch (HttpRequestException ex)
{
Console.WriteLine($"Błąd HTTP w GetEdiCustomerOrdersTranslationsAsync: {ex.Message}");
return null;
}
}
public async Task<int> DeleteEdiCustomerOrderTranslateAsync(EdiCustomerOrderTranslateDto ediCustomerOrderTranslateDto)
{
HttpResponseMessage responseMessage =
await DeleteAsync($"api/EdiCustomerOrdersTranslations/?id={ediCustomerOrderTranslateDto.Id}");
return responseMessage.IsSuccessStatusCode ? 1 : 0;
}
}