Skip to content

Commit

Permalink
Merge pull request #807 from NoxOrg/feature/571-noxgenerators-associa…
Browse files Browse the repository at this point in the history
…te-an-entity-using-relatedkey

571 Associate an Entity using relatedKey
  • Loading branch information
rochar authored Sep 18, 2023
2 parents 9124a56 + 8aaaf32 commit 9cbbb91
Show file tree
Hide file tree
Showing 119 changed files with 4,996 additions and 1,884 deletions.
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
Loading

0 comments on commit 9cbbb91

Please sign in to comment.