Commit 4749c4c 1 parent 609af1a commit 4749c4c Copy full SHA for 4749c4c
File tree 9 files changed +123
-3
lines changed
Desktop/Ws.Desktop.Models/Features
Ws.DeviceControl.Api/App/Features/Admins/PalletMen
Ws.DeviceControl.Models/Dto
Libs/Ws.Shared/Api/ValueTypes
9 files changed +123
-3
lines changed Original file line number Diff line number Diff line change 1
1
using System . Text . Json . Serialization ;
2
- using Ws . Desktop . Models . ValueTypes ;
2
+ using Ws . Shared . Api . ValueTypes ;
3
3
4
4
namespace Ws . Desktop . Models . Features . PalletMen ;
5
5
Original file line number Diff line number Diff line change 1
1
using System . Text . Json . Serialization ;
2
- using Ws . Desktop . Models . ValueTypes ;
2
+ using Ws . Shared . Api . ValueTypes ;
3
3
4
4
namespace Ws . Desktop . Models . Features . Pallets . Output ;
5
5
Original file line number Diff line number Diff line change
1
+ using Ws . DeviceControl . Models . Dto . Admins . PalletMen . Queries ;
2
+
3
+ namespace Ws . DeviceControl . Api . App . Features . Admins . PalletMen . Common ;
4
+
5
+ public interface IPalletManService
6
+ {
7
+ #region Queries
8
+
9
+ Task < PalletManDto > GetByIdAsync ( Guid id ) ;
10
+ Task < List < PalletManDto > > GetAllByProductionSiteAsync ( Guid productionSiteId ) ;
11
+
12
+ #endregion
13
+ }
Original file line number Diff line number Diff line change
1
+ using Ws . Database . EntityFramework . Entities . Ref . PalletMen ;
2
+ using Ws . DeviceControl . Models . Dto . Admins . PalletMen . Queries ;
3
+
4
+ namespace Ws . DeviceControl . Api . App . Features . Admins . PalletMen . Impl . Expressions ;
5
+
6
+ public static class PalletManExpressions
7
+ {
8
+ public static Expression < Func < PalletManEntity , PalletManDto > > ToDto =>
9
+ palletMan => new ( )
10
+ {
11
+ Id = palletMan . Id ,
12
+ Id1C = palletMan . Uid1C ,
13
+ Fio = new ( )
14
+ {
15
+ Name = palletMan . Name ,
16
+ Surname = palletMan . Surname ,
17
+ Patronymic = palletMan . Patronymic
18
+ } ,
19
+ Password = palletMan . Password ,
20
+ Warehouse = new ( )
21
+ {
22
+ Id = palletMan . Warehouse . Id ,
23
+ Name = palletMan . Warehouse . Name
24
+ } ,
25
+ CreateDt = palletMan . CreateDt ,
26
+ ChangeDt = palletMan . ChangeDt
27
+ } ;
28
+ }
Original file line number Diff line number Diff line change
1
+ using Ws . Database . EntityFramework . Entities . Ref . PalletMen ;
2
+ using Ws . DeviceControl . Api . App . Features . Admins . PalletMen . Common ;
3
+ using Ws . DeviceControl . Api . App . Features . Admins . PalletMen . Impl . Expressions ;
4
+ using Ws . DeviceControl . Models . Dto . Admins . PalletMen . Queries ;
5
+
6
+ namespace Ws . DeviceControl . Api . App . Features . Admins . PalletMen . Impl ;
7
+
8
+ public class PalletManApiService ( WsDbContext dbContext ) : IPalletManService
9
+ {
10
+ #region Queries
11
+
12
+ public Task < List < PalletManDto > > GetAllByProductionSiteAsync ( Guid productionSiteId )
13
+ {
14
+ return dbContext . PalletMen
15
+ . AsNoTracking ( )
16
+ . Where ( i => i . Warehouse . ProductionSite . Id == productionSiteId )
17
+ . Select ( PalletManExpressions . ToDto )
18
+ . ToListAsync ( ) ;
19
+ }
20
+
21
+ public async Task < PalletManDto > GetByIdAsync ( Guid id )
22
+ {
23
+ PalletManEntity ? palletMan = await dbContext . PalletMen . FindAsync ( id ) ;
24
+ if ( palletMan == null ) throw new KeyNotFoundException ( ) ;
25
+ return PalletManExpressions . ToDto . Compile ( ) . Invoke ( palletMan ) ;
26
+ }
27
+
28
+ #endregion
29
+ }
Original file line number Diff line number Diff line change
1
+ using Ws . DeviceControl . Api . App . Features . Admins . PalletMen . Common ;
2
+ using Ws . DeviceControl . Models . Dto . Admins . PalletMen . Queries ;
3
+
4
+ namespace Ws . DeviceControl . Api . App . Features . Admins . PalletMen ;
5
+
6
+ [ ApiController ]
7
+ [ Route ( "api/pallet-men/" ) ]
8
+ public class PrinterController ( IPalletManService palletManService )
9
+ {
10
+ #region Queries
11
+
12
+ [ HttpGet ]
13
+ public Task < List < PalletManDto > > GetAllByProductionSite ( [ FromQuery ( Name = "productionSite" ) ] Guid productionSiteId ) =>
14
+ palletManService . GetAllByProductionSiteAsync ( productionSiteId ) ;
15
+
16
+ [ HttpGet ( "{id:guid}" ) ]
17
+ public Task < PalletManDto > GetById ( [ FromRoute ] Guid id ) => palletManService . GetByIdAsync ( id ) ;
18
+
19
+ #endregion
20
+ }
Original file line number Diff line number Diff line change
1
+ using System . Text . Json . Serialization ;
2
+ using Ws . DeviceControl . Models . Dto . Shared ;
3
+ using Ws . Shared . Api . ValueTypes ;
4
+
5
+ namespace Ws . DeviceControl . Models . Dto . Admins . PalletMen . Queries ;
6
+
7
+ public class PalletManDto
8
+ {
9
+ [ JsonPropertyName ( "id" ) ]
10
+ public required Guid Id { get ; init ; }
11
+
12
+ [ JsonPropertyName ( "id1C" ) ]
13
+ public required Guid Id1C { get ; init ; }
14
+
15
+ [ JsonPropertyName ( "fio" ) ]
16
+ public required Fio Fio { get ; init ; }
17
+
18
+ [ JsonPropertyName ( "password" ) ]
19
+ public required string Password { get ; init ; }
20
+
21
+ [ JsonPropertyName ( "warehouse" ) ]
22
+ public required ProxyDto Warehouse { get ; init ; }
23
+
24
+ [ JsonPropertyName ( "createDt" ) ]
25
+ public required DateTime CreateDt { get ; init ; }
26
+
27
+ [ JsonPropertyName ( "changeDt" ) ]
28
+ public required DateTime ChangeDt { get ; init ; }
29
+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ public record PrinterDto
18
18
public required IPAddress Ip { get ; set ; }
19
19
20
20
[ JsonPropertyName ( "type" ) ]
21
+ [ JsonConverter ( typeof ( EnumJsonConverter < PrinterTypes > ) ) ]
21
22
public required PrinterTypes Type { get ; set ; }
22
23
23
24
[ JsonPropertyName ( "createDt" ) ]
Original file line number Diff line number Diff line change 1
1
using System . Text . Json . Serialization ;
2
2
using Ws . Shared . Extensions ;
3
3
4
- namespace Ws . Desktop . Models . ValueTypes ;
4
+ namespace Ws . Shared . Api . ValueTypes ;
5
5
6
6
public sealed record Fio
7
7
{
You can’t perform that action at this time.
0 commit comments