* Added managing EdiCustomerOrderTranslations
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
namespace FaKrosnoApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class EdiCustomerOrdersTranslationsController(IEdiCustomerOrderTranslateService service) : Controller
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<EdiCustomerOrderTranslateDto>>> GetAll()
|
||||||
|
{
|
||||||
|
IEnumerable<EdiCustomerOrderTranslateDto?> ediCustomerOrdersTranlations = await service.GetAll();
|
||||||
|
return Ok(ediCustomerOrdersTranlations);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete]
|
||||||
|
public async Task<IActionResult> Delete([FromQuery] int id)
|
||||||
|
{
|
||||||
|
await service.Delete(id);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -90,8 +90,6 @@ public class HangfireJobsController(
|
|||||||
[HttpPost("delete")]
|
[HttpPost("delete")]
|
||||||
public async Task<IActionResult> DeleteTask([FromBody] TaskSchedulerDto taskSchedulerDto)
|
public async Task<IActionResult> DeleteTask([FromBody] TaskSchedulerDto taskSchedulerDto)
|
||||||
{
|
{
|
||||||
var taskSchedulerByTaskName = await service.GetTaskSchedulerByTaskName(taskSchedulerDto.Name);
|
|
||||||
Console.WriteLine(taskSchedulerByTaskName.RowPointer);
|
|
||||||
int result = await service.DeleteTaskScheduler(taskSchedulerDto.RowPointer);
|
int result = await service.DeleteTaskScheduler(taskSchedulerDto.RowPointer);
|
||||||
|
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ builder.Services.AddAutoMapper(typeof(FaKrosnoMappingProfile), typeof(SytelineSa
|
|||||||
builder.Services.AddScoped<IScheduleOrderService, ScheduleOrderService>();
|
builder.Services.AddScoped<IScheduleOrderService, ScheduleOrderService>();
|
||||||
builder.Services.AddScoped<IScheduleOrderDetailsService, ScheduleOrderDetailsService>();
|
builder.Services.AddScoped<IScheduleOrderDetailsService, ScheduleOrderDetailsService>();
|
||||||
builder.Services.AddScoped<IEdiCustomerOrderService, EdiCustomerOrderService>();
|
builder.Services.AddScoped<IEdiCustomerOrderService, EdiCustomerOrderService>();
|
||||||
|
builder.Services.AddScoped<IEdiCustomerOrderTranslateService, EdiCustomerOrderTranslateService>();
|
||||||
builder.Services.AddScoped<IErrorLogService, ErrorLogService>();
|
builder.Services.AddScoped<IErrorLogService, ErrorLogService>();
|
||||||
builder.Services.AddScoped<ICustomerOrderService, CustomerOrderService>();
|
builder.Services.AddScoped<ICustomerOrderService, CustomerOrderService>();
|
||||||
builder.Services.AddScoped<IEmailService, EmailService>();
|
builder.Services.AddScoped<IEmailService, EmailService>();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<main class="container-fluid d-flex flex-column h-100">
|
<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"
|
<div class="bb-top-row px-4 d-flex justify-content-between align-items-center mb-3 shadow-sm"
|
||||||
style="background-color: #f8f9fa;">
|
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">
|
<img src="logo.svg" class="me-2" width="35" height="35" alt="Icon">
|
||||||
<h3 class="text-primary m-0">FA Krosno Manager</h3>
|
<h3 class="text-primary m-0">FA Krosno Manager</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -44,6 +44,7 @@ builder.Services.AddRazorComponents()
|
|||||||
|
|
||||||
builder.Services.AddScoped<ScheduleOrderService>();
|
builder.Services.AddScoped<ScheduleOrderService>();
|
||||||
builder.Services.AddScoped<EdiCustomerOrderService>();
|
builder.Services.AddScoped<EdiCustomerOrderService>();
|
||||||
|
builder.Services.AddScoped<EdiCustomerOrderTranslateService>();
|
||||||
builder.Services.AddScoped<CustomerOrderService>();
|
builder.Services.AddScoped<CustomerOrderService>();
|
||||||
builder.Services.AddScoped<HangfireService>();
|
builder.Services.AddScoped<HangfireService>();
|
||||||
builder.Services.AddScoped<RoleService>();
|
builder.Services.AddScoped<RoleService>();
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
|
||||||
|
namespace SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
public class EdiCustomerOrderTranslateService(SytelineSaAppDbContext context, IMapper mapper) : IEdiCustomerOrderTranslateService
|
||||||
|
{
|
||||||
|
public async Task<IEnumerable<EdiCustomerOrderTranslateDto>> GetAll()
|
||||||
|
{
|
||||||
|
return await context.EdiCustomerOrderTranslates.Select(x => mapper.Map<EdiCustomerOrderTranslateDto>(x))
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Delete(int id)
|
||||||
|
{
|
||||||
|
var entity = await context.EdiCustomerOrderTranslates.FindAsync(id);
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
context.EdiCustomerOrderTranslates.Remove(entity);
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
|
||||||
|
namespace SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
|
public interface IEdiCustomerOrderTranslateService
|
||||||
|
{
|
||||||
|
Task<IEnumerable<EdiCustomerOrderTranslateDto>> GetAll();
|
||||||
|
Task Delete(int id);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user