Skip to content

Commit 1c0eec3

Browse files
committed
UPDATE: add IsShipped, IsDeleted to Pallet
1 parent d1edebe commit 1c0eec3

File tree

14 files changed

+1437
-9
lines changed

14 files changed

+1437
-9
lines changed

Src/Apps/Desktop/Ws.Desktop.Api/App/Features/Pallets/Extensions/PalletExtensions.cs

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public static IQueryable<PalletInfo> ToPalletInfo(this IQueryable<PalletEntity>
4444
ProdDt = result.Pallet.ProductDt,
4545
CreateDt = result.Pallet.CreateDt,
4646
Kneadings = result.Labels.Select(i => (ushort)i.Kneading).ToHashSet(),
47+
DeletedAt = result.Pallet.DeletedAt,
48+
IsShipped = result.Pallet.IsShipped
4749
});
4850
}
4951

Src/Apps/Desktop/Ws.Desktop.Models/Features/Pallets/Output/PalletInfo.cs

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ public sealed record PalletInfo
3535
[JsonPropertyName("createDt")]
3636
public required DateTime CreateDt { get; init; }
3737

38+
[JsonPropertyName("deletedAt")]
39+
public required DateTime? DeletedAt { get; init; }
40+
41+
[JsonPropertyName("isShipped")]
42+
public required bool IsShipped { get; init; }
43+
3844
[JsonPropertyName("weightTray")]
3945
public required decimal WeightTray { get; init; }
4046

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using Ws.PalychExchangeApi.Features.Pallets.Dto;
2+
3+
namespace Ws.PalychExchangeApi.Features.Pallets.Common;
4+
5+
public interface IPalletService
6+
{
7+
PalletUpdateStatus Update(PalletUpdateDto dto);
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Xml.Serialization;
2+
3+
namespace Ws.PalychExchangeApi.Features.Pallets.Dto;
4+
5+
[XmlRoot(ElementName = "ResponseType")]
6+
public class PalletMsgWrapper
7+
{
8+
[XmlElement(ElementName = "Status")]
9+
public PalletUpdateStatus Status { get; set; } = new();
10+
}
11+
12+
public class PalletUpdateStatus
13+
{
14+
[XmlAttribute(AttributeName = "IsSuccess")]
15+
public bool IsSuccess { get; set; }
16+
17+
[XmlAttribute(AttributeName = "Message")]
18+
public string Message { get; set; } = string.Empty;
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Xml.Serialization;
2+
3+
namespace Ws.PalychExchangeApi.Features.Pallets.Dto;
4+
5+
6+
[XmlRoot(ElementName = "Pallet")]
7+
public class PalletUpdateWrapper
8+
{
9+
[XmlElement(ElementName = "Record")]
10+
public PalletUpdateDto Pallet { get; set; } = new();
11+
}
12+
13+
public class PalletUpdateDto
14+
{
15+
[XmlAttribute(AttributeName = "Number")]
16+
public string Number { get; set; } = string.Empty;
17+
18+
[XmlAttribute(AttributeName = "IsDelete")]
19+
public bool IsDelete { get; set; }
20+
21+
[XmlAttribute(AttributeName = "IsShipped")]
22+
public bool IsShipped { get; set; }
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Ws.PalychExchangeApi.Features.Pallets.Common;
4+
using Ws.PalychExchangeApi.Features.Pallets.Dto;
5+
6+
namespace Ws.PalychExchangeApi.Features.Pallets;
7+
8+
[ApiController]
9+
[AllowAnonymous]
10+
[Route("api/pallets")]
11+
public sealed class PalletController(IPalletService palletService) : ControllerBase
12+
{
13+
[HttpPost("update")]
14+
[Produces("application/xml")]
15+
public PalletMsgWrapper Load([FromBody] PalletUpdateWrapper wrapper) => new()
16+
{
17+
Status = palletService.Update(wrapper.Pallet)
18+
};
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Ws.Database.EntityFramework;
2+
using Ws.Database.EntityFramework.Entities.Print.Pallets;
3+
using Ws.PalychExchangeApi.Features.Pallets.Common;
4+
using Ws.PalychExchangeApi.Features.Pallets.Dto;
5+
6+
namespace Ws.PalychExchangeApi.Features.Pallets.Services;
7+
8+
internal class PalletService(WsDbContext context) : IPalletService
9+
{
10+
public PalletUpdateStatus Update(PalletUpdateDto dto)
11+
{
12+
PalletUpdateStatus status = new() { IsSuccess = true };
13+
14+
PalletEntity? pallet = context.Pallets.FirstOrDefault(i => i.Number == dto.Number);
15+
16+
if (pallet == null)
17+
{
18+
status.IsSuccess = false;
19+
status.Message = $"Паллета {dto.Number}: не найдена";
20+
}
21+
else
22+
{
23+
pallet.IsShipped = dto.IsShipped;
24+
pallet.DeletedAt = dto.IsDelete ? DateTime.Now : null;
25+
context.SaveChanges();
26+
}
27+
28+
return status;
29+
}
30+
}

Src/Apps/Exchange/Ws.PalychExchangeApi/Program.cs

+3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
using Ws.PalychExchangeApi.Features.Characteristics.Services;
1111
using Ws.PalychExchangeApi.Features.Clips.Common;
1212
using Ws.PalychExchangeApi.Features.Clips.Services;
13+
using Ws.PalychExchangeApi.Features.Pallets.Common;
1314
using Ws.PalychExchangeApi.Features.Plus.Common;
1415
using Ws.PalychExchangeApi.Features.Plus.Services;
16+
1517
using Ws.PalychExchangeApi.Middlewares;
1618

1719
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
@@ -29,6 +31,7 @@
2931
builder.Services.AddScoped<IBrandService, BrandService>();
3032
builder.Services.AddScoped<IPluService, PluService>();
3133
builder.Services.AddScoped<ICharacteristicService, CharacteristicService>();
34+
builder.Services.AddScoped<IPalletService, Ws.PalychExchangeApi.Features.Pallets.Services.PalletService>();
3235

3336
#pragma warning disable CA1416
3437

Src/Infrastructure/Ws.Database.EntityFramework/Entities/Print/Pallets/PalletEntity.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class PalletEntity : EfEntityBase
2222
#region Date
2323

2424
public DateTime CreateDt { get; init; }
25-
public DateTime? DeletedAt { get; init; }
25+
public DateTime? DeletedAt { get; set; }
2626

2727
#endregion
2828
}

0 commit comments

Comments
 (0)