-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #807 from NoxOrg/feature/571-noxgenerators-associa…
…te-an-entity-using-relatedkey 571 Associate an Entity using relatedKey
- Loading branch information
Showing
119 changed files
with
4,996 additions
and
1,884 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...CodeGenerator/Application.Commands.CreateRefBookingToBookingFeesForCommissionCommand.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
| ||
// Generated | ||
|
||
#nullable enable | ||
|
||
using MediatR; | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore; | ||
using Nox.Application; | ||
using Nox.Application.Commands; | ||
using Nox.Factories; | ||
using Nox.Solution; | ||
using Nox.Types; | ||
|
||
using Cryptocash.Infrastructure.Persistence; | ||
using Cryptocash.Domain; | ||
using Cryptocash.Application.Dto; | ||
|
||
namespace Cryptocash.Application.Commands; | ||
public record CreateRefBookingToBookingFeesForCommissionCommand(BookingKeyDto EntityKeyDto, CommissionKeyDto RelatedEntityKeyDto) : IRequest <bool>; | ||
|
||
public partial class CreateRefBookingToBookingFeesForCommissionCommandHandler: CommandBase<CreateRefBookingToBookingFeesForCommissionCommand, Booking>, | ||
IRequestHandler <CreateRefBookingToBookingFeesForCommissionCommand, bool> | ||
{ | ||
public CryptocashDbContext DbContext { get; } | ||
|
||
public CreateRefBookingToBookingFeesForCommissionCommandHandler( | ||
CryptocashDbContext dbContext, | ||
NoxSolution noxSolution, | ||
IServiceProvider serviceProvider): base(noxSolution, serviceProvider) | ||
{ | ||
DbContext = dbContext; | ||
} | ||
|
||
public async Task<bool> Handle(CreateRefBookingToBookingFeesForCommissionCommand request, CancellationToken cancellationToken) | ||
{ | ||
OnExecuting(request); | ||
var keyId = CreateNoxTypeForKey<Booking, Nox.Types.Guid>("Id", request.EntityKeyDto.keyId); | ||
var entity = await DbContext.Bookings.FindAsync(keyId); | ||
if (entity == null) | ||
{ | ||
return false; | ||
} | ||
var relatedKeyId = CreateNoxTypeForKey<Commission, Nox.Types.AutoNumber>("Id", request.RelatedEntityKeyDto.keyId); | ||
var relatedEntity = await DbContext.Commissions.FindAsync(relatedKeyId); | ||
if (relatedEntity == null) | ||
{ | ||
return false; | ||
} | ||
|
||
entity.CreateRefToCommissionBookingFeesForCommission(relatedEntity); | ||
|
||
OnCompleted(request, entity); | ||
|
||
DbContext.Entry(entity).State = EntityState.Modified; | ||
var result = await DbContext.SaveChangesAsync(); | ||
return true; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...or.NoxCodeGenerator/Application.Commands.CreateRefBookingToBookingForCustomerCommand.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
| ||
// Generated | ||
|
||
#nullable enable | ||
|
||
using MediatR; | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore; | ||
using Nox.Application; | ||
using Nox.Application.Commands; | ||
using Nox.Factories; | ||
using Nox.Solution; | ||
using Nox.Types; | ||
|
||
using Cryptocash.Infrastructure.Persistence; | ||
using Cryptocash.Domain; | ||
using Cryptocash.Application.Dto; | ||
|
||
namespace Cryptocash.Application.Commands; | ||
public record CreateRefBookingToBookingForCustomerCommand(BookingKeyDto EntityKeyDto, CustomerKeyDto RelatedEntityKeyDto) : IRequest <bool>; | ||
|
||
public partial class CreateRefBookingToBookingForCustomerCommandHandler: CommandBase<CreateRefBookingToBookingForCustomerCommand, Booking>, | ||
IRequestHandler <CreateRefBookingToBookingForCustomerCommand, bool> | ||
{ | ||
public CryptocashDbContext DbContext { get; } | ||
|
||
public CreateRefBookingToBookingForCustomerCommandHandler( | ||
CryptocashDbContext dbContext, | ||
NoxSolution noxSolution, | ||
IServiceProvider serviceProvider): base(noxSolution, serviceProvider) | ||
{ | ||
DbContext = dbContext; | ||
} | ||
|
||
public async Task<bool> Handle(CreateRefBookingToBookingForCustomerCommand request, CancellationToken cancellationToken) | ||
{ | ||
OnExecuting(request); | ||
var keyId = CreateNoxTypeForKey<Booking, Nox.Types.Guid>("Id", request.EntityKeyDto.keyId); | ||
var entity = await DbContext.Bookings.FindAsync(keyId); | ||
if (entity == null) | ||
{ | ||
return false; | ||
} | ||
var relatedKeyId = CreateNoxTypeForKey<Customer, Nox.Types.AutoNumber>("Id", request.RelatedEntityKeyDto.keyId); | ||
var relatedEntity = await DbContext.Customers.FindAsync(relatedKeyId); | ||
if (relatedEntity == null) | ||
{ | ||
return false; | ||
} | ||
|
||
entity.CreateRefToCustomerBookingForCustomer(relatedEntity); | ||
|
||
OnCompleted(request, entity); | ||
|
||
DbContext.Entry(entity).State = EntityState.Modified; | ||
var result = await DbContext.SaveChangesAsync(); | ||
return true; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...odeGenerator/Application.Commands.CreateRefBookingToBookingRelatedTransactionCommand.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
| ||
// Generated | ||
|
||
#nullable enable | ||
|
||
using MediatR; | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore; | ||
using Nox.Application; | ||
using Nox.Application.Commands; | ||
using Nox.Factories; | ||
using Nox.Solution; | ||
using Nox.Types; | ||
|
||
using Cryptocash.Infrastructure.Persistence; | ||
using Cryptocash.Domain; | ||
using Cryptocash.Application.Dto; | ||
|
||
namespace Cryptocash.Application.Commands; | ||
public record CreateRefBookingToBookingRelatedTransactionCommand(BookingKeyDto EntityKeyDto, TransactionKeyDto RelatedEntityKeyDto) : IRequest <bool>; | ||
|
||
public partial class CreateRefBookingToBookingRelatedTransactionCommandHandler: CommandBase<CreateRefBookingToBookingRelatedTransactionCommand, Booking>, | ||
IRequestHandler <CreateRefBookingToBookingRelatedTransactionCommand, bool> | ||
{ | ||
public CryptocashDbContext DbContext { get; } | ||
|
||
public CreateRefBookingToBookingRelatedTransactionCommandHandler( | ||
CryptocashDbContext dbContext, | ||
NoxSolution noxSolution, | ||
IServiceProvider serviceProvider): base(noxSolution, serviceProvider) | ||
{ | ||
DbContext = dbContext; | ||
} | ||
|
||
public async Task<bool> Handle(CreateRefBookingToBookingRelatedTransactionCommand request, CancellationToken cancellationToken) | ||
{ | ||
OnExecuting(request); | ||
var keyId = CreateNoxTypeForKey<Booking, Nox.Types.Guid>("Id", request.EntityKeyDto.keyId); | ||
var entity = await DbContext.Bookings.FindAsync(keyId); | ||
if (entity == null) | ||
{ | ||
return false; | ||
} | ||
var relatedKeyId = CreateNoxTypeForKey<Transaction, Nox.Types.AutoNumber>("Id", request.RelatedEntityKeyDto.keyId); | ||
var relatedEntity = await DbContext.Transactions.FindAsync(relatedKeyId); | ||
if (relatedEntity == null) | ||
{ | ||
return false; | ||
} | ||
|
||
entity.CreateRefToTransactionBookingRelatedTransaction(relatedEntity); | ||
|
||
OnCompleted(request, entity); | ||
|
||
DbContext.Entry(entity).State = EntityState.Modified; | ||
var result = await DbContext.SaveChangesAsync(); | ||
return true; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...Generator/Application.Commands.CreateRefBookingToBookingRelatedVendingMachineCommand.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
| ||
// Generated | ||
|
||
#nullable enable | ||
|
||
using MediatR; | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore; | ||
using Nox.Application; | ||
using Nox.Application.Commands; | ||
using Nox.Factories; | ||
using Nox.Solution; | ||
using Nox.Types; | ||
|
||
using Cryptocash.Infrastructure.Persistence; | ||
using Cryptocash.Domain; | ||
using Cryptocash.Application.Dto; | ||
|
||
namespace Cryptocash.Application.Commands; | ||
public record CreateRefBookingToBookingRelatedVendingMachineCommand(BookingKeyDto EntityKeyDto, VendingMachineKeyDto RelatedEntityKeyDto) : IRequest <bool>; | ||
|
||
public partial class CreateRefBookingToBookingRelatedVendingMachineCommandHandler: CommandBase<CreateRefBookingToBookingRelatedVendingMachineCommand, Booking>, | ||
IRequestHandler <CreateRefBookingToBookingRelatedVendingMachineCommand, bool> | ||
{ | ||
public CryptocashDbContext DbContext { get; } | ||
|
||
public CreateRefBookingToBookingRelatedVendingMachineCommandHandler( | ||
CryptocashDbContext dbContext, | ||
NoxSolution noxSolution, | ||
IServiceProvider serviceProvider): base(noxSolution, serviceProvider) | ||
{ | ||
DbContext = dbContext; | ||
} | ||
|
||
public async Task<bool> Handle(CreateRefBookingToBookingRelatedVendingMachineCommand request, CancellationToken cancellationToken) | ||
{ | ||
OnExecuting(request); | ||
var keyId = CreateNoxTypeForKey<Booking, Nox.Types.Guid>("Id", request.EntityKeyDto.keyId); | ||
var entity = await DbContext.Bookings.FindAsync(keyId); | ||
if (entity == null) | ||
{ | ||
return false; | ||
} | ||
var relatedKeyId = CreateNoxTypeForKey<VendingMachine, Nox.Types.Guid>("Id", request.RelatedEntityKeyDto.keyId); | ||
var relatedEntity = await DbContext.VendingMachines.FindAsync(relatedKeyId); | ||
if (relatedEntity == null) | ||
{ | ||
return false; | ||
} | ||
|
||
entity.CreateRefToVendingMachineBookingRelatedVendingMachine(relatedEntity); | ||
|
||
OnCompleted(request, entity); | ||
|
||
DbContext.Entry(entity).State = EntityState.Modified; | ||
var result = await DbContext.SaveChangesAsync(); | ||
return true; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...Application.Commands.CreateRefCashStockOrderToCashStockOrderForVendingMachineCommand.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
| ||
// Generated | ||
|
||
#nullable enable | ||
|
||
using MediatR; | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore; | ||
using Nox.Application; | ||
using Nox.Application.Commands; | ||
using Nox.Factories; | ||
using Nox.Solution; | ||
using Nox.Types; | ||
|
||
using Cryptocash.Infrastructure.Persistence; | ||
using Cryptocash.Domain; | ||
using Cryptocash.Application.Dto; | ||
|
||
namespace Cryptocash.Application.Commands; | ||
public record CreateRefCashStockOrderToCashStockOrderForVendingMachineCommand(CashStockOrderKeyDto EntityKeyDto, VendingMachineKeyDto RelatedEntityKeyDto) : IRequest <bool>; | ||
|
||
public partial class CreateRefCashStockOrderToCashStockOrderForVendingMachineCommandHandler: CommandBase<CreateRefCashStockOrderToCashStockOrderForVendingMachineCommand, CashStockOrder>, | ||
IRequestHandler <CreateRefCashStockOrderToCashStockOrderForVendingMachineCommand, bool> | ||
{ | ||
public CryptocashDbContext DbContext { get; } | ||
|
||
public CreateRefCashStockOrderToCashStockOrderForVendingMachineCommandHandler( | ||
CryptocashDbContext dbContext, | ||
NoxSolution noxSolution, | ||
IServiceProvider serviceProvider): base(noxSolution, serviceProvider) | ||
{ | ||
DbContext = dbContext; | ||
} | ||
|
||
public async Task<bool> Handle(CreateRefCashStockOrderToCashStockOrderForVendingMachineCommand request, CancellationToken cancellationToken) | ||
{ | ||
OnExecuting(request); | ||
var keyId = CreateNoxTypeForKey<CashStockOrder, Nox.Types.AutoNumber>("Id", request.EntityKeyDto.keyId); | ||
var entity = await DbContext.CashStockOrders.FindAsync(keyId); | ||
if (entity == null) | ||
{ | ||
return false; | ||
} | ||
var relatedKeyId = CreateNoxTypeForKey<VendingMachine, Nox.Types.Guid>("Id", request.RelatedEntityKeyDto.keyId); | ||
var relatedEntity = await DbContext.VendingMachines.FindAsync(relatedKeyId); | ||
if (relatedEntity == null) | ||
{ | ||
return false; | ||
} | ||
|
||
entity.CreateRefToVendingMachineCashStockOrderForVendingMachine(relatedEntity); | ||
|
||
OnCompleted(request, entity); | ||
|
||
DbContext.Entry(entity).State = EntityState.Modified; | ||
var result = await DbContext.SaveChangesAsync(); | ||
return true; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...pplication.Commands.CreateRefCashStockOrderToCashStockOrderReviewedByEmployeeCommand.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
| ||
// Generated | ||
|
||
#nullable enable | ||
|
||
using MediatR; | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore; | ||
using Nox.Application; | ||
using Nox.Application.Commands; | ||
using Nox.Factories; | ||
using Nox.Solution; | ||
using Nox.Types; | ||
|
||
using Cryptocash.Infrastructure.Persistence; | ||
using Cryptocash.Domain; | ||
using Cryptocash.Application.Dto; | ||
|
||
namespace Cryptocash.Application.Commands; | ||
public record CreateRefCashStockOrderToCashStockOrderReviewedByEmployeeCommand(CashStockOrderKeyDto EntityKeyDto, EmployeeKeyDto RelatedEntityKeyDto) : IRequest <bool>; | ||
|
||
public partial class CreateRefCashStockOrderToCashStockOrderReviewedByEmployeeCommandHandler: CommandBase<CreateRefCashStockOrderToCashStockOrderReviewedByEmployeeCommand, CashStockOrder>, | ||
IRequestHandler <CreateRefCashStockOrderToCashStockOrderReviewedByEmployeeCommand, bool> | ||
{ | ||
public CryptocashDbContext DbContext { get; } | ||
|
||
public CreateRefCashStockOrderToCashStockOrderReviewedByEmployeeCommandHandler( | ||
CryptocashDbContext dbContext, | ||
NoxSolution noxSolution, | ||
IServiceProvider serviceProvider): base(noxSolution, serviceProvider) | ||
{ | ||
DbContext = dbContext; | ||
} | ||
|
||
public async Task<bool> Handle(CreateRefCashStockOrderToCashStockOrderReviewedByEmployeeCommand request, CancellationToken cancellationToken) | ||
{ | ||
OnExecuting(request); | ||
var keyId = CreateNoxTypeForKey<CashStockOrder, Nox.Types.AutoNumber>("Id", request.EntityKeyDto.keyId); | ||
var entity = await DbContext.CashStockOrders.FindAsync(keyId); | ||
if (entity == null) | ||
{ | ||
return false; | ||
} | ||
var relatedKeyId = CreateNoxTypeForKey<Employee, Nox.Types.AutoNumber>("Id", request.RelatedEntityKeyDto.keyId); | ||
var relatedEntity = await DbContext.Employees.FindAsync(relatedKeyId); | ||
if (relatedEntity == null) | ||
{ | ||
return false; | ||
} | ||
|
||
entity.CreateRefToEmployeeCashStockOrderReviewedByEmployee(relatedEntity); | ||
|
||
OnCompleted(request, entity); | ||
|
||
DbContext.Entry(entity).State = EntityState.Modified; | ||
var result = await DbContext.SaveChangesAsync(); | ||
return true; | ||
} | ||
} |
Oops, something went wrong.