diff --git a/Sheaft.Application.Commands/Legal/CheckLegalsDeclarationRequiredCommand.cs b/Sheaft.Application.Commands/Legal/CheckLegalsDeclarationRequiredCommand.cs deleted file mode 100644 index 019ebad1d..000000000 --- a/Sheaft.Application.Commands/Legal/CheckLegalsDeclarationRequiredCommand.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using Sheaft.Core; -using Newtonsoft.Json; - -namespace Sheaft.Application.Commands -{ - public class CheckLegalsDeclarationRequiredCommand : Command - { - [JsonConstructor] - public CheckLegalsDeclarationRequiredCommand(RequestUser requestUser) : base(requestUser) - { - } - - public Guid UserId { get; set; } - } -} diff --git a/Sheaft.Application.Handlers/Commands/LegalCommandsHandler.cs b/Sheaft.Application.Handlers/Commands/LegalCommandsHandler.cs index 05e42148d..d389dfe65 100644 --- a/Sheaft.Application.Handlers/Commands/LegalCommandsHandler.cs +++ b/Sheaft.Application.Handlers/Commands/LegalCommandsHandler.cs @@ -7,10 +7,6 @@ using System.Threading.Tasks; using System.Threading; using Sheaft.Domain.Models; -using Sheaft.Domain.Enums; -using System.Linq; -using Microsoft.EntityFrameworkCore; -using Sheaft.Application.Events; namespace Sheaft.Application.Handlers { @@ -20,8 +16,7 @@ public class LegalCommandsHandler : ResultsHandler, IRequestHandler>, IRequestHandler>, IRequestHandler>, - IRequestHandler>, - IRequestHandler> + IRequestHandler> { private readonly IPspService _pspService; @@ -257,37 +252,5 @@ public async Task> Handle(CheckConsumerLegalConfigurationCommand re return Ok(true); }); } - - public async Task> Handle(CheckLegalsDeclarationRequiredCommand request, CancellationToken token) - { - return await ExecuteAsync(request, async () => - { - var legal = await _context.GetSingleAsync(b => b.User.Id == request.UserId, token); - if (legal.User.Kind != ProfileKind.Producer) - return Ok(false); - - if (legal.DeclarationRequired) - return Ok(legal.DeclarationRequired); - - var currentMonth = DateTimeOffset.UtcNow.Month; - var cumulatedMonthAmount = await _context.PurchaseOrders - .Get(po => - po.Vendor.Id == request.UserId && - po.Sender.Kind == ProfileKind.Consumer && - po.Status == PurchaseOrderStatus.Delivered && - po.DeliveredOn.HasValue && - po.DeliveredOn.Value.Month == currentMonth) - .SumAsync(po => po.TotalOnSalePrice, token); - - if (cumulatedMonthAmount >= 150) - { - legal.SetDeclarationRequired(true); - await _context.SaveChangesAsync(token); - _mediatr.Post(new ProducerDeclarationRequiredEvent(request.RequestUser) { ProducerId = request.UserId }); - } - - return Ok(legal.DeclarationRequired); - }); - } } } \ No newline at end of file diff --git a/Sheaft.Application.Handlers/Commands/PayoutCommandsHandler.cs b/Sheaft.Application.Handlers/Commands/PayoutCommandsHandler.cs index 28e683123..b10570191 100644 --- a/Sheaft.Application.Handlers/Commands/PayoutCommandsHandler.cs +++ b/Sheaft.Application.Handlers/Commands/PayoutCommandsHandler.cs @@ -149,13 +149,13 @@ public async Task> Handle(CreatePayoutCommand request, Cancellation if (!checkConfigurationResult.Success) return Failed(checkConfigurationResult.Exception); - var producerLegals = await _context.GetSingleAsync(c => c.User.Id == request.ProducerId, token); - if (producerLegals.DeclarationRequired) - { - var checkDocumentsResult = await _mediatr.Process(new EnsureProducerDocumentsValidatedCommand(request.RequestUser) { ProducerId = request.ProducerId }, token); - if (!checkDocumentsResult.Success) - return Failed(checkDocumentsResult.Exception); + var producerLegals = await _context.GetSingleAsync(c => c.User.Id == request.ProducerId, token); + var checkDocumentsResult = await _mediatr.Process(new EnsureProducerDocumentsValidatedCommand(request.RequestUser) { ProducerId = request.ProducerId }, token); + if (!checkDocumentsResult.Success) + return Failed(checkDocumentsResult.Exception); + if (producerLegals.Kind == LegalKind.Business) + { var checkDeclarationResult = await _mediatr.Process(new EnsureDeclarationIsValidatedCommand(request.RequestUser) { ProducerId = request.ProducerId }, token); if (!checkDeclarationResult.Success) return Failed(checkDeclarationResult.Exception); @@ -175,19 +175,16 @@ public async Task> Handle(CreatePayoutCommand request, Cancellation token); var amount = transfers.Sum(t => t.Credited); - var fees = 0m; - if (producerLegals.DeclarationRequired) - { - var hasAlreadyPaidComission = await _context.AnyAsync( - p => p.Fees > 0 - && p.DebitedWallet.User.Id == request.ProducerId - && p.Status != TransactionStatus.Failed, - token); + var fees = 0m; + var hasAlreadyPaidComission = await _context.AnyAsync( + p => p.Fees > 0 + && p.DebitedWallet.User.Id == request.ProducerId + && p.Status != TransactionStatus.Failed, + token); - fees = hasAlreadyPaidComission || amount < _pspOptions.ProducerFees ? 0m : _pspOptions.ProducerFees; - if (!hasAlreadyPaidComission && fees == 0m) - return Failed(new Exception("Invalid fees for payout without paid commission.")); - } + fees = hasAlreadyPaidComission || amount < _pspOptions.ProducerFees ? 0m : _pspOptions.ProducerFees; + if (!hasAlreadyPaidComission && fees == 0m) + return Failed(new Exception("Invalid fees for payout without paid commission.")); using (var transaction = await _context.BeginTransactionAsync(token)) { diff --git a/Sheaft.Application.Handlers/Commands/PurchaseOrderCommandsHandler.cs b/Sheaft.Application.Handlers/Commands/PurchaseOrderCommandsHandler.cs index 7ef969472..d65369d51 100644 --- a/Sheaft.Application.Handlers/Commands/PurchaseOrderCommandsHandler.cs +++ b/Sheaft.Application.Handlers/Commands/PurchaseOrderCommandsHandler.cs @@ -240,10 +240,8 @@ public async Task> Handle(DeliverPurchaseOrderCommand request, Canc await _context.SaveChangesAsync(token); var producerLegals = await _context.GetSingleAsync(c => c.User.Id == purchaseOrder.Vendor.Id, token); - if(!producerLegals.DeclarationRequired) - _mediatr.Post(new CheckLegalsDeclarationRequiredCommand(request.RequestUser) { UserId = purchaseOrder.Vendor.Id }); - _mediatr.Schedule(new CreateTransferCommand(request.RequestUser) { PurchaseOrderId = purchaseOrder.Id }, TimeSpan.FromDays(7)); + return Ok(true); }); } diff --git a/Sheaft.Domain/BusinessLegal.cs b/Sheaft.Domain/BusinessLegal.cs index a4f15eeea..f5ba97727 100644 --- a/Sheaft.Domain/BusinessLegal.cs +++ b/Sheaft.Domain/BusinessLegal.cs @@ -20,7 +20,6 @@ public BusinessLegal(Guid id, Business business, LegalKind kind, string name, st SetAddress(address); SetSiret(siret); SetVatIdentifier(vatIdentifier); - DeclarationRequired = false; } public string Name { get; set; } @@ -29,8 +28,6 @@ public BusinessLegal(Guid id, Business business, LegalKind kind, string name, st public string VatIdentifier { get; private set; } public virtual LegalAddress Address { get; private set; } public virtual Declaration Declaration { get; private set; } - public bool DeclarationRequired { get; private set; } - public bool IsComplete => !DeclarationRequired || (DeclarationRequired && Declaration?.Status == DeclarationStatus.Validated && Documents.All(d => d.Status == DocumentStatus.Validated)); public void SetDeclaration() { @@ -40,15 +37,6 @@ public void SetDeclaration() Declaration = new Declaration(Guid.NewGuid()); } - - public void SetDeclarationRequired(bool validationRequired) - { - if (DeclarationRequired) - throw new ValidationException(MessageKind.Legal_Cannot_Unrequire_Declaration); - - DeclarationRequired = validationRequired; - } - public void SetSiret(string siret) { if (siret.IsNotNullAndIsEmptyOrWhiteSpace()) diff --git a/Sheaft.Infrastructure.Persistence/Configurations/BusinessLegalConfiguration.cs b/Sheaft.Infrastructure.Persistence/Configurations/BusinessLegalConfiguration.cs index 78589f228..672003c0d 100644 --- a/Sheaft.Infrastructure.Persistence/Configurations/BusinessLegalConfiguration.cs +++ b/Sheaft.Infrastructure.Persistence/Configurations/BusinessLegalConfiguration.cs @@ -10,7 +10,6 @@ public void Configure(EntityTypeBuilder entity) { entity.Property(c => c.Siret).IsRequired(); entity.Property(c => c.VatIdentifier); - entity.Ignore(c => c.IsComplete); entity.OwnsOne(c => c.Address, e => { e.ToTable("BusinessLegalAddresses"); diff --git a/Sheaft.Infrastructure.Persistence/Migrations/20201130203206_Remove_DeclarationRequired_Legal.Designer.cs b/Sheaft.Infrastructure.Persistence/Migrations/20201130203206_Remove_DeclarationRequired_Legal.Designer.cs new file mode 100644 index 000000000..e82da76ea --- /dev/null +++ b/Sheaft.Infrastructure.Persistence/Migrations/20201130203206_Remove_DeclarationRequired_Legal.Designer.cs @@ -0,0 +1,3272 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Sheaft.Domain.Enums; +using Sheaft.Infrastructure.Persistence; + +namespace Sheaft.Infrastructure.Persistence.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20201130203206_Remove_DeclarationRequired_Legal")] + partial class Remove_DeclarationRequired_Legal + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("app") + .HasAnnotation("ProductVersion", "3.1.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Sheaft.Domain.Models.Agreement", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("CreatedByUid") + .HasColumnType("bigint"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("DeliveryModeUid") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Reason") + .HasColumnType("nvarchar(max)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StoreUid") + .HasColumnType("bigint"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.HasKey("Uid"); + + b.HasIndex("CreatedByUid"); + + b.HasIndex("DeliveryModeUid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("StoreUid"); + + b.HasIndex("Uid", "Id", "StoreUid", "DeliveryModeUid", "RemovedOn"); + + b.ToTable("Agreements"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Country", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Alpha2") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Uid"); + + b.HasIndex("Alpha2") + .IsUnique(); + + b.HasIndex("Uid", "Id", "Alpha2"); + + b.ToTable("Countries"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.DeliveryMode", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Available") + .HasColumnType("bit"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("LockOrderHoursBeforeDelivery") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("ProducerUid") + .HasColumnType("bigint"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.HasKey("Uid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("ProducerUid"); + + b.HasIndex("Uid", "Id", "ProducerUid", "RemovedOn"); + + b.ToTable("DeliveryModes"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Department", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ConsumersCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("LevelUid") + .HasColumnType("bigint"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Points") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Position") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("ProducersCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("RegionUid") + .HasColumnType("bigint"); + + b.Property("RequiredProducers") + .HasColumnType("int"); + + b.Property("StoresCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.HasKey("Uid"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LevelUid"); + + b.HasIndex("RegionUid"); + + b.HasIndex("Uid", "Id", "RegionUid", "LevelUid"); + + b.ToTable("Departments"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Donation", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("AuthorUid") + .HasColumnType("bigint"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Credited") + .HasColumnType("decimal(10,2)"); + + b.Property("CreditedWalletUid") + .HasColumnType("bigint"); + + b.Property("Debited") + .HasColumnType("decimal(10,2)"); + + b.Property("DebitedWalletUid") + .HasColumnType("bigint"); + + b.Property("ExecutedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Fees") + .HasColumnType("decimal(10,2)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Identifier") + .HasColumnType("nvarchar(450)"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("OrderUid") + .HasColumnType("bigint"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("ResultCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResultMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.HasKey("Uid"); + + b.HasIndex("AuthorUid"); + + b.HasIndex("CreditedWalletUid"); + + b.HasIndex("DebitedWalletUid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Identifier"); + + b.HasIndex("OrderUid"); + + b.HasIndex("Uid", "Id", "AuthorUid", "OrderUid", "CreditedWalletUid", "DebitedWalletUid", "RemovedOn"); + + b.ToTable("Donations"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Job", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Archived") + .HasColumnType("bit"); + + b.Property("Command") + .HasColumnType("nvarchar(max)"); + + b.Property("CompletedOn") + .HasColumnType("datetimeoffset"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("File") + .HasColumnType("nvarchar(max)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("Message") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Queue") + .HasColumnType("nvarchar(max)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Retried") + .HasColumnType("int"); + + b.Property("StartedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.Property("UserUid") + .HasColumnType("bigint"); + + b.HasKey("Uid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("UserUid"); + + b.HasIndex("Uid", "Id", "UserUid", "RemovedOn"); + + b.ToTable("Jobs"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Legal", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.Property("UserKind") + .HasColumnType("int"); + + b.Property("UserUid") + .HasColumnType("bigint"); + + b.HasKey("Uid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("UserUid") + .IsUnique(); + + b.HasIndex("Uid", "Id"); + + b.ToTable("Legals"); + + b.HasDiscriminator("UserKind"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Level", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("RequiredPoints") + .HasColumnType("int"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.HasKey("Uid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Uid", "Id", "RemovedOn"); + + b.ToTable("Levels"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Nationality", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Alpha2") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Uid"); + + b.HasIndex("Alpha2") + .IsUnique(); + + b.HasIndex("Uid", "Id", "Alpha2"); + + b.ToTable("Nationalities"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Notification", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("Method") + .HasColumnType("nvarchar(max)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Unread") + .HasColumnType("bit"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.Property("UserUid") + .HasColumnType("bigint"); + + b.HasKey("Uid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("UserUid"); + + b.HasIndex("Uid", "Id", "UserUid", "RemovedOn"); + + b.ToTable("Notifications"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Order", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Donate") + .HasColumnType("decimal(10,2)"); + + b.Property("DonationKind") + .HasColumnType("int"); + + b.Property("DonationUid") + .HasColumnType("bigint"); + + b.Property("ExpiredOn") + .HasColumnType("datetimeoffset"); + + b.Property("FeesFixedAmount") + .HasColumnType("decimal(10,2)"); + + b.Property("FeesPercent") + .HasColumnType("decimal(10,4)"); + + b.Property("FeesPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("InternalFeesPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("LinesCount") + .HasColumnType("int"); + + b.Property("PayinUid") + .HasColumnType("bigint"); + + b.Property("ProductsCount") + .HasColumnType("int"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("ReturnablesCount") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalOnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalProductOnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalProductVatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalProductWholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalReturnableOnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalReturnableVatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalReturnableWholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalVatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalWeight") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalWholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.Property("UserUid") + .HasColumnType("bigint"); + + b.HasKey("Uid"); + + b.HasIndex("DonationUid") + .IsUnique() + .HasFilter("[DonationUid] IS NOT NULL"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("PayinUid") + .IsUnique() + .HasFilter("[PayinUid] IS NOT NULL"); + + b.HasIndex("UserUid"); + + b.HasIndex("Uid", "Id", "UserUid", "RemovedOn"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.OrderDelivery", b => + { + b.Property("OrderUid") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryModeUid") + .HasColumnType("bigint"); + + b.Property("ExpectedDeliveryDate") + .HasColumnType("datetimeoffset"); + + b.HasKey("OrderUid", "Id"); + + b.HasIndex("DeliveryModeUid"); + + b.ToTable("OrderDeliveries"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.OrderProduct", b => + { + b.Property("OrderUid") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProducerUid") + .HasColumnType("bigint"); + + b.Property("Quantity") + .IsConcurrencyToken() + .HasColumnType("int"); + + b.Property("Reference") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ReturnableName") + .HasColumnType("nvarchar(max)"); + + b.Property("ReturnableOnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("ReturnableVat") + .HasColumnType("decimal(10,2)"); + + b.Property("ReturnableVatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("ReturnableWholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("ReturnablesCount") + .HasColumnType("int"); + + b.Property("TotalOnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalProductOnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalProductVatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalProductWholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalReturnableOnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalReturnableVatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalReturnableWholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalVatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalWeight") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalWholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("UnitOnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("UnitVatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("UnitWeight") + .HasColumnType("decimal(10,2)"); + + b.Property("UnitWholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("Vat") + .HasColumnType("decimal(10,2)"); + + b.HasKey("OrderUid", "Id"); + + b.HasIndex("ProducerUid"); + + b.ToTable("OrderProducts"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Payin", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("AuthorUid") + .HasColumnType("bigint"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Credited") + .HasColumnType("decimal(10,2)"); + + b.Property("CreditedWalletUid") + .HasColumnType("bigint"); + + b.Property("Debited") + .HasColumnType("decimal(10,2)"); + + b.Property("ExecutedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Fees") + .HasColumnType("decimal(10,2)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Identifier") + .HasColumnType("nvarchar(450)"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("OrderUid") + .HasColumnType("bigint"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("ResultCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResultMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.HasKey("Uid"); + + b.HasIndex("AuthorUid"); + + b.HasIndex("CreditedWalletUid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Identifier"); + + b.HasIndex("OrderUid"); + + b.HasIndex("Uid", "Id", "AuthorUid", "OrderUid", "CreditedWalletUid", "RemovedOn"); + + b.ToTable("Payins"); + + b.HasDiscriminator("Kind"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.PaymentMethod", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Identifier") + .HasColumnType("nvarchar(450)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.Property("UserUid") + .HasColumnType("bigint"); + + b.HasKey("Uid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Identifier"); + + b.HasIndex("UserUid"); + + b.HasIndex("Uid", "Id", "Identifier", "UserUid", "RemovedOn"); + + b.ToTable("PaymentMethods"); + + b.HasDiscriminator("Kind"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Payout", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("AuthorUid") + .HasColumnType("bigint"); + + b.Property("BankAccountUid") + .HasColumnType("bigint"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Credited") + .HasColumnType("decimal(10,2)"); + + b.Property("Debited") + .HasColumnType("decimal(10,2)"); + + b.Property("DebitedWalletUid") + .HasColumnType("bigint"); + + b.Property("ExecutedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Fees") + .HasColumnType("decimal(10,2)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Identifier") + .HasColumnType("nvarchar(450)"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("ResultCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResultMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.HasKey("Uid"); + + b.HasIndex("AuthorUid"); + + b.HasIndex("BankAccountUid"); + + b.HasIndex("DebitedWalletUid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Identifier"); + + b.HasIndex("Uid", "Id", "AuthorUid", "BankAccountUid", "DebitedWalletUid", "RemovedOn"); + + b.ToTable("Payouts"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.ProducerTag", b => + { + b.Property("ProducerUid") + .HasColumnType("bigint"); + + b.Property("TagUid") + .HasColumnType("bigint"); + + b.HasKey("ProducerUid", "TagUid"); + + b.HasIndex("TagUid"); + + b.ToTable("ProducerTags"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Product", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Available") + .HasColumnType("bit"); + + b.Property("Conditioning") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("OnSalePricePerUnit") + .HasColumnType("decimal(10,2)"); + + b.Property("Picture") + .HasColumnType("nvarchar(max)"); + + b.Property("ProducerUid") + .HasColumnType("bigint"); + + b.Property("QuantityPerUnit") + .HasColumnType("decimal(10,3)"); + + b.Property("Rating") + .HasColumnType("decimal(10,2)"); + + b.Property("RatingsCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Reference") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("ReturnableUid") + .HasColumnType("bigint"); + + b.Property("Unit") + .HasColumnType("int"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.Property("Vat") + .HasColumnType("decimal(10,2)"); + + b.Property("VatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("VatPricePerUnit") + .HasColumnType("decimal(10,2)"); + + b.Property("VisibleToConsumers") + .HasColumnType("bit"); + + b.Property("VisibleToStores") + .HasColumnType("bit"); + + b.Property("Weight") + .HasColumnType("decimal(10,2)"); + + b.Property("WholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("WholeSalePricePerUnit") + .HasColumnType("decimal(10,2)"); + + b.HasKey("Uid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("ProducerUid"); + + b.HasIndex("ReturnableUid"); + + b.HasIndex("ProducerUid", "Reference") + .IsUnique(); + + b.HasIndex("Uid", "Id", "ProducerUid", "ReturnableUid", "RemovedOn"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.ProductTag", b => + { + b.Property("ProductUid") + .HasColumnType("bigint"); + + b.Property("TagUid") + .HasColumnType("bigint"); + + b.HasKey("ProductUid", "TagUid"); + + b.HasIndex("TagUid"); + + b.ToTable("ProductTags"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.PurchaseOrder", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("AcceptedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Comment") + .HasColumnType("nvarchar(max)"); + + b.Property("CompletedOn") + .HasColumnType("datetimeoffset"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("DeliveredOn") + .HasColumnType("datetimeoffset"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("LinesCount") + .HasColumnType("int"); + + b.Property("OrderUid") + .HasColumnType("bigint"); + + b.Property("ProductsCount") + .HasColumnType("int"); + + b.Property("PurchaseOrderSenderUid") + .HasColumnType("bigint"); + + b.Property("PurchaseOrderVendorUid") + .HasColumnType("bigint"); + + b.Property("Reason") + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("ReturnablesCount") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalOnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalProductOnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalProductVatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalProductWholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalReturnableOnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalReturnableVatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalReturnableWholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalVatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalWeight") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalWholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TransferUid") + .HasColumnType("bigint"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.Property("WithdrawnOn") + .HasColumnType("datetimeoffset"); + + b.HasKey("Uid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("OrderUid"); + + b.HasIndex("PurchaseOrderSenderUid") + .IsUnique(); + + b.HasIndex("PurchaseOrderVendorUid") + .IsUnique(); + + b.HasIndex("TransferUid") + .IsUnique() + .HasFilter("[TransferUid] IS NOT NULL"); + + b.HasIndex("PurchaseOrderVendorUid", "Reference") + .IsUnique(); + + b.HasIndex("OrderUid", "Uid", "Id", "PurchaseOrderVendorUid", "PurchaseOrderSenderUid", "RemovedOn"); + + b.ToTable("PurchaseOrders"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.PurchaseOrderProduct", b => + { + b.Property("PurchaseOrderUid") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Quantity") + .IsConcurrencyToken() + .HasColumnType("int"); + + b.Property("Reference") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ReturnableName") + .HasColumnType("nvarchar(max)"); + + b.Property("ReturnableOnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("ReturnableVat") + .HasColumnType("decimal(10,2)"); + + b.Property("ReturnableVatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("ReturnableWholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("ReturnablesCount") + .HasColumnType("int"); + + b.Property("TotalOnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalProductOnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalProductVatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalProductWholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalReturnableOnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalReturnableVatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalReturnableWholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalVatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalWeight") + .HasColumnType("decimal(10,2)"); + + b.Property("TotalWholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("UnitOnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("UnitVatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("UnitWeight") + .HasColumnType("decimal(10,2)"); + + b.Property("UnitWholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("Vat") + .HasColumnType("decimal(10,2)"); + + b.HasKey("PurchaseOrderUid", "Id"); + + b.ToTable("PurchaseOrderProducts"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.PurchaseOrderSender", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .HasColumnType("nvarchar(max)"); + + b.Property("Picture") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Uid"); + + b.HasIndex("Id"); + + b.ToTable("PurchaseOrderSenders"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.PurchaseOrderVendor", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .HasColumnType("nvarchar(max)"); + + b.Property("Picture") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Uid"); + + b.HasIndex("Id"); + + b.ToTable("PurchaseOrderVendors"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.QuickOrder", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.Property("UserUid") + .HasColumnType("bigint"); + + b.HasKey("Uid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("UserUid"); + + b.HasIndex("Uid", "Id", "UserUid", "RemovedOn"); + + b.ToTable("QuickOrders"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.QuickOrderProduct", b => + { + b.Property("QuickOrderUid") + .HasColumnType("bigint"); + + b.Property("ProductUid") + .HasColumnType("bigint"); + + b.Property("Quantity") + .IsConcurrencyToken() + .HasColumnType("int"); + + b.HasKey("QuickOrderUid", "ProductUid"); + + b.HasIndex("ProductUid"); + + b.ToTable("QuickOrderProducts"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Rating", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Comment") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductUid") + .HasColumnType("bigint"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.Property("UserUid") + .HasColumnType("bigint"); + + b.Property("Value") + .HasColumnType("decimal(10,2)"); + + b.HasKey("Uid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("ProductUid"); + + b.HasIndex("UserUid"); + + b.HasIndex("Uid", "Id", "ProductUid", "UserUid", "RemovedOn"); + + b.ToTable("Ratings"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Refund", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("AuthorUid") + .HasColumnType("bigint"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Credited") + .HasColumnType("decimal(10,2)"); + + b.Property("Debited") + .HasColumnType("decimal(10,2)"); + + b.Property("DebitedWalletUid") + .HasColumnType("bigint"); + + b.Property("ExecutedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Fees") + .HasColumnType("decimal(10,2)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Identifier") + .HasColumnType("nvarchar(450)"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("ResultCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResultMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.HasKey("Uid"); + + b.HasIndex("AuthorUid"); + + b.HasIndex("DebitedWalletUid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Identifier"); + + b.HasIndex("Uid", "Id", "AuthorUid", "DebitedWalletUid", "RemovedOn"); + + b.ToTable("Refunds"); + + b.HasDiscriminator("Kind"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Region", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ConsumersCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Points") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Position") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("ProducersCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("RequiredProducers") + .HasColumnType("int"); + + b.Property("StoresCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.HasKey("Uid"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Uid", "Id"); + + b.ToTable("Regions"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Returnable", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Kind") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OnSalePrice") + .HasColumnType("decimal(10,2)"); + + b.Property("ProducerUid") + .HasColumnType("bigint"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.Property("Vat") + .HasColumnType("decimal(10,2)"); + + b.Property("VatPrice") + .HasColumnType("decimal(10,2)"); + + b.Property("WholeSalePrice") + .HasColumnType("decimal(10,2)"); + + b.HasKey("Uid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("ProducerUid"); + + b.HasIndex("Uid", "Id", "RemovedOn"); + + b.ToTable("Returnables"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Reward", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Contact") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("DepartmentUid") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("LevelUid") + .HasColumnType("bigint"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .HasColumnType("nvarchar(max)"); + + b.Property("Picture") + .HasColumnType("nvarchar(max)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.Property("Url") + .HasColumnType("nvarchar(max)"); + + b.Property("WinnerUid") + .HasColumnType("bigint"); + + b.HasKey("Uid"); + + b.HasIndex("DepartmentUid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LevelUid"); + + b.HasIndex("WinnerUid"); + + b.HasIndex("Uid", "Id", "DepartmentUid", "LevelUid", "RemovedOn"); + + b.ToTable("Rewards"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Sponsoring", b => + { + b.Property("SponsorUid") + .HasColumnType("bigint"); + + b.Property("SponsoredUid") + .HasColumnType("bigint"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.HasKey("SponsorUid", "SponsoredUid"); + + b.HasIndex("SponsoredUid"); + + b.ToTable("Sponsorings"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.StoreTag", b => + { + b.Property("StoreUid") + .HasColumnType("bigint"); + + b.Property("TagUid") + .HasColumnType("bigint"); + + b.HasKey("StoreUid", "TagUid"); + + b.HasIndex("TagUid"); + + b.ToTable("StoreTags"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Tag", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Available") + .HasColumnType("bit"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Icon") + .HasColumnType("nvarchar(max)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Picture") + .HasColumnType("nvarchar(max)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.HasKey("Uid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Uid", "Id", "RemovedOn"); + + b.ToTable("Tags"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Transfer", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("AuthorUid") + .HasColumnType("bigint"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Credited") + .HasColumnType("decimal(10,2)"); + + b.Property("CreditedWalletUid") + .HasColumnType("bigint"); + + b.Property("Debited") + .HasColumnType("decimal(10,2)"); + + b.Property("DebitedWalletUid") + .HasColumnType("bigint"); + + b.Property("ExecutedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Fees") + .HasColumnType("decimal(10,2)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Identifier") + .HasColumnType("nvarchar(450)"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("PayoutUid") + .HasColumnType("bigint"); + + b.Property("PurchaseOrderUid") + .HasColumnType("bigint"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("ResultCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResultMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.HasKey("Uid"); + + b.HasIndex("AuthorUid"); + + b.HasIndex("CreditedWalletUid"); + + b.HasIndex("DebitedWalletUid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Identifier"); + + b.HasIndex("PayoutUid"); + + b.HasIndex("PurchaseOrderUid"); + + b.HasIndex("Uid", "Id", "AuthorUid", "PurchaseOrderUid", "CreditedWalletUid", "DebitedWalletUid", "RemovedOn"); + + b.ToTable("Transfers"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.User", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Identifier") + .HasColumnType("nvarchar(450)"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .HasColumnType("nvarchar(max)"); + + b.Property("Picture") + .HasColumnType("nvarchar(max)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("SponsorshipCode") + .HasColumnType("nvarchar(max)"); + + b.Property("TotalPoints") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.HasKey("Uid"); + + b.HasIndex("Email") + .IsUnique(); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Identifier"); + + b.HasIndex("Uid", "Id", "RemovedOn"); + + b.ToTable("Users"); + + b.HasDiscriminator("Kind"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Wallet", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Balance") + .HasColumnType("decimal(10,2)"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("ExternalUpdatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Identifier") + .HasColumnType("nvarchar(450)"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RemovedOn") + .HasColumnType("datetimeoffset"); + + b.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b.Property("UserUid") + .HasColumnType("bigint"); + + b.HasKey("Uid"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Identifier"); + + b.HasIndex("UserUid"); + + b.HasIndex("Uid", "Id", "UserUid", "RemovedOn"); + + b.ToTable("Wallets"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.BusinessLegal", b => + { + b.HasBaseType("Sheaft.Domain.Models.Legal"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Siret") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("VatIdentifier") + .HasColumnType("nvarchar(max)"); + + b.HasDiscriminator().HasValue(1); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.ConsumerLegal", b => + { + b.HasBaseType("Sheaft.Domain.Models.Legal"); + + b.HasDiscriminator().HasValue(0); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.CardPayin", b => + { + b.HasBaseType("Sheaft.Domain.Models.Payin"); + + b.Property("CardUid") + .HasColumnType("bigint"); + + b.HasIndex("CardUid"); + + b.HasDiscriminator().HasValue(1); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.WebPayin", b => + { + b.HasBaseType("Sheaft.Domain.Models.Payin"); + + b.Property("RedirectUrl") + .HasColumnType("nvarchar(max)"); + + b.HasDiscriminator().HasValue(0); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.BankAccount", b => + { + b.HasBaseType("Sheaft.Domain.Models.PaymentMethod"); + + b.Property("BIC") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("City") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("int"); + + b.Property("IBAN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Line1") + .HasColumnType("nvarchar(max)"); + + b.Property("Line2") + .HasColumnType("nvarchar(max)"); + + b.Property("Owner") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Zipcode") + .HasColumnType("nvarchar(max)"); + + b.HasDiscriminator().HasValue(0); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Card", b => + { + b.HasBaseType("Sheaft.Domain.Models.PaymentMethod"); + + b.HasDiscriminator().HasValue(1); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.PayinRefund", b => + { + b.HasBaseType("Sheaft.Domain.Models.Refund"); + + b.Property("PayinUid") + .HasColumnType("bigint"); + + b.Property("PurchaseOrderUid") + .HasColumnType("bigint"); + + b.HasIndex("PayinUid"); + + b.HasIndex("PurchaseOrderUid"); + + b.HasDiscriminator().HasValue(300); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Admin", b => + { + b.HasBaseType("Sheaft.Domain.Models.User"); + + b.HasDiscriminator().HasValue(4); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Business", b => + { + b.HasBaseType("Sheaft.Domain.Models.User"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("OpenForNewBusiness") + .HasColumnType("bit"); + + b.HasDiscriminator(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Consumer", b => + { + b.HasBaseType("Sheaft.Domain.Models.User"); + + b.Property("Anonymous") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.HasDiscriminator().HasValue(2); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Support", b => + { + b.HasBaseType("Sheaft.Domain.Models.User"); + + b.HasDiscriminator().HasValue(3); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Producer", b => + { + b.HasBaseType("Sheaft.Domain.Models.Business"); + + b.Property("CanDirectSell") + .HasColumnType("bit"); + + b.Property("NotSubjectToVat") + .HasColumnType("bit"); + + b.HasDiscriminator().HasValue(0); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Store", b => + { + b.HasBaseType("Sheaft.Domain.Models.Business"); + + b.HasDiscriminator().HasValue(1); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Agreement", b => + { + b.HasOne("Sheaft.Domain.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedByUid"); + + b.HasOne("Sheaft.Domain.Models.DeliveryMode", "Delivery") + .WithMany() + .HasForeignKey("DeliveryModeUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Store", "Store") + .WithMany() + .HasForeignKey("StoreUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Sheaft.Domain.Models.TimeSlotHour", "SelectedHours", b1 => + { + b1.Property("AgreementUid") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("Day") + .HasColumnType("int"); + + b1.Property("From") + .HasColumnType("time"); + + b1.Property("To") + .HasColumnType("time"); + + b1.HasKey("AgreementUid", "Id"); + + b1.ToTable("AgreementSelectedHours"); + + b1.WithOwner() + .HasForeignKey("AgreementUid"); + }); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.DeliveryMode", b => + { + b.HasOne("Sheaft.Domain.Models.Producer", "Producer") + .WithMany() + .HasForeignKey("ProducerUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Sheaft.Domain.Models.DeliveryAddress", "Address", b1 => + { + b1.Property("DeliveryModeUid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("City") + .HasColumnType("nvarchar(max)"); + + b1.Property("Country") + .HasColumnType("int"); + + b1.Property("Latitude") + .HasColumnType("float"); + + b1.Property("Line1") + .HasColumnType("nvarchar(max)"); + + b1.Property("Line2") + .HasColumnType("nvarchar(max)"); + + b1.Property("Longitude") + .HasColumnType("float"); + + b1.Property("Zipcode") + .HasColumnType("nvarchar(max)"); + + b1.HasKey("DeliveryModeUid"); + + b1.ToTable("DeliveryModes"); + + b1.WithOwner() + .HasForeignKey("DeliveryModeUid"); + }); + + b.OwnsMany("Sheaft.Domain.Models.TimeSlotHour", "OpeningHours", b1 => + { + b1.Property("DeliveryModeUid") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("Day") + .HasColumnType("int"); + + b1.Property("From") + .HasColumnType("time"); + + b1.Property("To") + .HasColumnType("time"); + + b1.HasKey("DeliveryModeUid", "Id"); + + b1.ToTable("DeliveryModeOpeningHours"); + + b1.WithOwner() + .HasForeignKey("DeliveryModeUid"); + }); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Department", b => + { + b.HasOne("Sheaft.Domain.Models.Level", "Level") + .WithMany() + .HasForeignKey("LevelUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Region", "Region") + .WithMany() + .HasForeignKey("RegionUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Donation", b => + { + b.HasOne("Sheaft.Domain.Models.User", "Author") + .WithMany() + .HasForeignKey("AuthorUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Wallet", "CreditedWallet") + .WithMany() + .HasForeignKey("CreditedWalletUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Wallet", "DebitedWallet") + .WithMany() + .HasForeignKey("DebitedWalletUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Order", "Order") + .WithMany() + .HasForeignKey("OrderUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Job", b => + { + b.HasOne("Sheaft.Domain.Models.User", "User") + .WithMany() + .HasForeignKey("UserUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Legal", b => + { + b.HasOne("Sheaft.Domain.Models.User", "User") + .WithOne() + .HasForeignKey("Sheaft.Domain.Models.Legal", "UserUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Sheaft.Domain.Models.Document", "Documents", b1 => + { + b1.Property("LegalUid") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b1.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b1.Property("Identifier") + .HasColumnType("nvarchar(450)"); + + b1.Property("Kind") + .HasColumnType("int"); + + b1.Property("Name") + .HasColumnType("nvarchar(max)"); + + b1.Property("ProcessedOn") + .HasColumnType("datetimeoffset"); + + b1.Property("ResultCode") + .HasColumnType("nvarchar(max)"); + + b1.Property("ResultMessage") + .HasColumnType("nvarchar(max)"); + + b1.Property("Status") + .HasColumnType("int"); + + b1.Property("UpdatedOn") + .IsConcurrencyToken() + .HasColumnType("datetimeoffset"); + + b1.HasKey("LegalUid", "Id"); + + b1.HasIndex("Id") + .IsUnique(); + + b1.HasIndex("Identifier"); + + b1.ToTable("Documents"); + + b1.WithOwner() + .HasForeignKey("LegalUid"); + + b1.OwnsMany("Sheaft.Domain.Models.Page", "Pages", b2 => + { + b2.Property("DocumentLegalUid") + .HasColumnType("bigint"); + + b2.Property("DocumentId") + .HasColumnType("uniqueidentifier"); + + b2.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b2.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b2.Property("Extension") + .HasColumnType("nvarchar(max)"); + + b2.Property("Filename") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b2.Property("Size") + .HasColumnType("bigint"); + + b2.Property("UploadedOn") + .HasColumnType("datetimeoffset"); + + b2.HasKey("DocumentLegalUid", "DocumentId", "Id"); + + b2.HasIndex("Id") + .IsUnique(); + + b2.ToTable("DocumentPages"); + + b2.WithOwner() + .HasForeignKey("DocumentLegalUid", "DocumentId"); + }); + }); + + b.OwnsOne("Sheaft.Domain.Models.Owner", "Owner", b1 => + { + b1.Property("LegalUid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("BirthDate") + .HasColumnType("datetimeoffset"); + + b1.Property("CountryOfResidence") + .HasColumnType("int"); + + b1.Property("Email") + .HasColumnType("nvarchar(max)"); + + b1.Property("FirstName") + .HasColumnType("nvarchar(max)"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastName") + .HasColumnType("nvarchar(max)"); + + b1.Property("Nationality") + .HasColumnType("int"); + + b1.HasKey("LegalUid"); + + b1.ToTable("Legals"); + + b1.WithOwner() + .HasForeignKey("LegalUid"); + + b1.OwnsOne("Sheaft.Domain.Models.OwnerAddress", "Address", b2 => + { + b2.Property("OwnerLegalUid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("City") + .HasColumnType("nvarchar(max)"); + + b2.Property("Country") + .HasColumnType("int"); + + b2.Property("Line1") + .HasColumnType("nvarchar(max)"); + + b2.Property("Line2") + .HasColumnType("nvarchar(max)"); + + b2.Property("Zipcode") + .HasColumnType("nvarchar(max)"); + + b2.HasKey("OwnerLegalUid"); + + b2.ToTable("Legals"); + + b2.WithOwner() + .HasForeignKey("OwnerLegalUid"); + }); + }); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Notification", b => + { + b.HasOne("Sheaft.Domain.Models.User", "User") + .WithMany() + .HasForeignKey("UserUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Order", b => + { + b.HasOne("Sheaft.Domain.Models.Donation", "Donation") + .WithOne() + .HasForeignKey("Sheaft.Domain.Models.Order", "DonationUid") + .OnDelete(DeleteBehavior.NoAction); + + b.HasOne("Sheaft.Domain.Models.Payin", "Payin") + .WithOne() + .HasForeignKey("Sheaft.Domain.Models.Order", "PayinUid") + .OnDelete(DeleteBehavior.NoAction); + + b.HasOne("Sheaft.Domain.Models.User", "User") + .WithMany() + .HasForeignKey("UserUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.OrderDelivery", b => + { + b.HasOne("Sheaft.Domain.Models.DeliveryMode", "DeliveryMode") + .WithMany() + .HasForeignKey("DeliveryModeUid"); + + b.HasOne("Sheaft.Domain.Models.Order", null) + .WithMany("Deliveries") + .HasForeignKey("OrderUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.OrderProduct", b => + { + b.HasOne("Sheaft.Domain.Models.Order", null) + .WithMany("Products") + .HasForeignKey("OrderUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.User", "Producer") + .WithMany() + .HasForeignKey("ProducerUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Payin", b => + { + b.HasOne("Sheaft.Domain.Models.User", "Author") + .WithMany() + .HasForeignKey("AuthorUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Wallet", "CreditedWallet") + .WithMany() + .HasForeignKey("CreditedWalletUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Order", "Order") + .WithMany() + .HasForeignKey("OrderUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.PaymentMethod", b => + { + b.HasOne("Sheaft.Domain.Models.User", "User") + .WithMany() + .HasForeignKey("UserUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Payout", b => + { + b.HasOne("Sheaft.Domain.Models.User", "Author") + .WithMany() + .HasForeignKey("AuthorUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.BankAccount", "BankAccount") + .WithMany() + .HasForeignKey("BankAccountUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Wallet", "DebitedWallet") + .WithMany() + .HasForeignKey("DebitedWalletUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.ProducerTag", b => + { + b.HasOne("Sheaft.Domain.Models.Producer", null) + .WithMany("Tags") + .HasForeignKey("ProducerUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Tag", "Tag") + .WithMany() + .HasForeignKey("TagUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Product", b => + { + b.HasOne("Sheaft.Domain.Models.Producer", "Producer") + .WithMany() + .HasForeignKey("ProducerUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Returnable", "Returnable") + .WithMany() + .HasForeignKey("ReturnableUid") + .OnDelete(DeleteBehavior.NoAction); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.ProductTag", b => + { + b.HasOne("Sheaft.Domain.Models.Product", null) + .WithMany("Tags") + .HasForeignKey("ProductUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Tag", "Tag") + .WithMany() + .HasForeignKey("TagUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.PurchaseOrder", b => + { + b.HasOne("Sheaft.Domain.Models.Order", null) + .WithMany("PurchaseOrders") + .HasForeignKey("OrderUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.PurchaseOrderSender", "Sender") + .WithOne() + .HasForeignKey("Sheaft.Domain.Models.PurchaseOrder", "PurchaseOrderSenderUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.PurchaseOrderVendor", "Vendor") + .WithOne() + .HasForeignKey("Sheaft.Domain.Models.PurchaseOrder", "PurchaseOrderVendorUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Transfer", "Transfer") + .WithOne() + .HasForeignKey("Sheaft.Domain.Models.PurchaseOrder", "TransferUid") + .OnDelete(DeleteBehavior.NoAction); + + b.OwnsOne("Sheaft.Domain.Models.ExpectedDelivery", "ExpectedDelivery", b1 => + { + b1.Property("PurchaseOrderUid") + .HasColumnType("bigint"); + + b1.Property("DeliveredOn") + .HasColumnType("datetimeoffset"); + + b1.Property("DeliveryStartedOn") + .HasColumnType("datetimeoffset"); + + b1.Property("ExpectedDeliveryDate") + .HasColumnType("datetimeoffset"); + + b1.Property("From") + .HasColumnType("time"); + + b1.Property("Kind") + .HasColumnType("int"); + + b1.Property("Name") + .HasColumnType("nvarchar(max)"); + + b1.Property("To") + .HasColumnType("time"); + + b1.HasKey("PurchaseOrderUid"); + + b1.ToTable("ExpectedDeliveries"); + + b1.WithOwner() + .HasForeignKey("PurchaseOrderUid"); + + b1.OwnsOne("Sheaft.Domain.Models.ExpectedAddress", "Address", b2 => + { + b2.Property("ExpectedDeliveryPurchaseOrderUid") + .HasColumnType("bigint"); + + b2.Property("City") + .HasColumnType("nvarchar(max)"); + + b2.Property("Country") + .HasColumnType("int"); + + b2.Property("Latitude") + .HasColumnType("float"); + + b2.Property("Line1") + .HasColumnType("nvarchar(max)"); + + b2.Property("Line2") + .HasColumnType("nvarchar(max)"); + + b2.Property("Longitude") + .HasColumnType("float"); + + b2.Property("Zipcode") + .HasColumnType("nvarchar(max)"); + + b2.HasKey("ExpectedDeliveryPurchaseOrderUid"); + + b2.ToTable("ExpectedDeliveries"); + + b2.WithOwner() + .HasForeignKey("ExpectedDeliveryPurchaseOrderUid"); + }); + }); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.PurchaseOrderProduct", b => + { + b.HasOne("Sheaft.Domain.Models.PurchaseOrder", null) + .WithMany("Products") + .HasForeignKey("PurchaseOrderUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.QuickOrder", b => + { + b.HasOne("Sheaft.Domain.Models.User", "User") + .WithMany() + .HasForeignKey("UserUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.QuickOrderProduct", b => + { + b.HasOne("Sheaft.Domain.Models.Product", "Product") + .WithMany() + .HasForeignKey("ProductUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.QuickOrder", null) + .WithMany("Products") + .HasForeignKey("QuickOrderUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Rating", b => + { + b.HasOne("Sheaft.Domain.Models.Product", null) + .WithMany("Ratings") + .HasForeignKey("ProductUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.User", "User") + .WithMany() + .HasForeignKey("UserUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Refund", b => + { + b.HasOne("Sheaft.Domain.Models.User", "Author") + .WithMany() + .HasForeignKey("AuthorUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Wallet", "DebitedWallet") + .WithMany() + .HasForeignKey("DebitedWalletUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Returnable", b => + { + b.HasOne("Sheaft.Domain.Models.Producer", "Producer") + .WithMany() + .HasForeignKey("ProducerUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Reward", b => + { + b.HasOne("Sheaft.Domain.Models.Department", "Department") + .WithMany() + .HasForeignKey("DepartmentUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Level", "Level") + .WithMany("Rewards") + .HasForeignKey("LevelUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Consumer", "Winner") + .WithMany() + .HasForeignKey("WinnerUid"); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Sponsoring", b => + { + b.HasOne("Sheaft.Domain.Models.User", "Sponsor") + .WithMany() + .HasForeignKey("SponsorUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.User", "Sponsored") + .WithMany() + .HasForeignKey("SponsoredUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.StoreTag", b => + { + b.HasOne("Sheaft.Domain.Models.Store", null) + .WithMany("Tags") + .HasForeignKey("StoreUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Tag", "Tag") + .WithMany() + .HasForeignKey("TagUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Transfer", b => + { + b.HasOne("Sheaft.Domain.Models.User", "Author") + .WithMany() + .HasForeignKey("AuthorUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Wallet", "CreditedWallet") + .WithMany() + .HasForeignKey("CreditedWalletUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Wallet", "DebitedWallet") + .WithMany() + .HasForeignKey("DebitedWalletUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.Payout", "Payout") + .WithMany("Transfers") + .HasForeignKey("PayoutUid") + .OnDelete(DeleteBehavior.NoAction); + + b.HasOne("Sheaft.Domain.Models.PurchaseOrder", "PurchaseOrder") + .WithMany() + .HasForeignKey("PurchaseOrderUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.User", b => + { + b.OwnsMany("Sheaft.Domain.Models.Points", "Points", b1 => + { + b1.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("Kind") + .HasColumnType("int"); + + b1.Property("Quantity") + .HasColumnType("int"); + + b1.Property("UserUid") + .HasColumnType("bigint"); + + b1.HasKey("Uid"); + + b1.HasIndex("Id") + .IsUnique(); + + b1.HasIndex("UserUid"); + + b1.ToTable("UserPoints"); + + b1.WithOwner() + .HasForeignKey("UserUid"); + }); + + b.OwnsOne("Sheaft.Domain.Models.UserAddress", "Address", b1 => + { + b1.Property("UserUid") + .HasColumnType("bigint"); + + b1.Property("City") + .HasColumnType("nvarchar(max)"); + + b1.Property("Country") + .HasColumnType("int"); + + b1.Property("DepartmentUid") + .HasColumnType("bigint"); + + b1.Property("Latitude") + .HasColumnType("float"); + + b1.Property("Line1") + .HasColumnType("nvarchar(max)"); + + b1.Property("Line2") + .HasColumnType("nvarchar(max)"); + + b1.Property("Longitude") + .HasColumnType("float"); + + b1.Property("Zipcode") + .HasColumnType("nvarchar(max)"); + + b1.HasKey("UserUid"); + + b1.HasIndex("DepartmentUid"); + + b1.ToTable("UserAddresses"); + + b1.HasOne("Sheaft.Domain.Models.Department", "Department") + .WithMany() + .HasForeignKey("DepartmentUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.WithOwner() + .HasForeignKey("UserUid"); + }); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Wallet", b => + { + b.HasOne("Sheaft.Domain.Models.User", "User") + .WithMany() + .HasForeignKey("UserUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.BusinessLegal", b => + { + b.OwnsOne("Sheaft.Domain.Models.Declaration", "Declaration", b1 => + { + b1.Property("BusinessLegalUid") + .HasColumnType("bigint"); + + b1.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("Identifier") + .HasColumnType("nvarchar(max)"); + + b1.Property("ProcessedOn") + .HasColumnType("datetimeoffset"); + + b1.Property("ReasonCode") + .HasColumnType("nvarchar(max)"); + + b1.Property("ReasonMessage") + .HasColumnType("nvarchar(max)"); + + b1.Property("Status") + .HasColumnType("int"); + + b1.Property("UpdatedOn") + .HasColumnType("datetimeoffset"); + + b1.HasKey("BusinessLegalUid"); + + b1.ToTable("Declarations"); + + b1.WithOwner() + .HasForeignKey("BusinessLegalUid"); + + b1.OwnsMany("Sheaft.Domain.Models.Ubo", "Ubos", b2 => + { + b2.Property("DeclarationBusinessLegalUid") + .HasColumnType("bigint"); + + b2.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b2.Property("BirthDate") + .HasColumnType("datetimeoffset"); + + b2.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b2.Property("FirstName") + .HasColumnType("nvarchar(max)"); + + b2.Property("Identifier") + .HasColumnType("nvarchar(450)"); + + b2.Property("LastName") + .HasColumnType("nvarchar(max)"); + + b2.Property("Nationality") + .HasColumnType("int"); + + b2.Property("UpdatedOn") + .HasColumnType("datetimeoffset"); + + b2.HasKey("DeclarationBusinessLegalUid", "Id"); + + b2.HasIndex("Id") + .IsUnique(); + + b2.HasIndex("Identifier"); + + b2.ToTable("DeclarationUbos"); + + b2.WithOwner() + .HasForeignKey("DeclarationBusinessLegalUid"); + + b2.OwnsOne("Sheaft.Domain.Models.BirthAddress", "BirthPlace", b3 => + { + b3.Property("UboDeclarationBusinessLegalUid") + .HasColumnType("bigint"); + + b3.Property("UboId") + .HasColumnType("uniqueidentifier"); + + b3.Property("City") + .HasColumnType("nvarchar(max)"); + + b3.Property("Country") + .HasColumnType("int"); + + b3.HasKey("UboDeclarationBusinessLegalUid", "UboId"); + + b3.ToTable("DeclarationUbos"); + + b3.WithOwner() + .HasForeignKey("UboDeclarationBusinessLegalUid", "UboId"); + }); + + b2.OwnsOne("Sheaft.Domain.Models.UboAddress", "Address", b3 => + { + b3.Property("UboDeclarationBusinessLegalUid") + .HasColumnType("bigint"); + + b3.Property("UboId") + .HasColumnType("uniqueidentifier"); + + b3.Property("City") + .HasColumnType("nvarchar(max)"); + + b3.Property("Country") + .HasColumnType("int"); + + b3.Property("Line1") + .HasColumnType("nvarchar(max)"); + + b3.Property("Line2") + .HasColumnType("nvarchar(max)"); + + b3.Property("Zipcode") + .HasColumnType("nvarchar(max)"); + + b3.HasKey("UboDeclarationBusinessLegalUid", "UboId"); + + b3.ToTable("DeclarationUbos"); + + b3.WithOwner() + .HasForeignKey("UboDeclarationBusinessLegalUid", "UboId"); + }); + }); + }); + + b.OwnsOne("Sheaft.Domain.Models.LegalAddress", "Address", b1 => + { + b1.Property("BusinessLegalUid") + .HasColumnType("bigint"); + + b1.Property("City") + .HasColumnType("nvarchar(max)"); + + b1.Property("Country") + .HasColumnType("int"); + + b1.Property("Line1") + .HasColumnType("nvarchar(max)"); + + b1.Property("Line2") + .HasColumnType("nvarchar(max)"); + + b1.Property("Zipcode") + .HasColumnType("nvarchar(max)"); + + b1.HasKey("BusinessLegalUid"); + + b1.ToTable("BusinessLegalAddresses"); + + b1.WithOwner() + .HasForeignKey("BusinessLegalUid"); + }); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.CardPayin", b => + { + b.HasOne("Sheaft.Domain.Models.Card", "Card") + .WithMany() + .HasForeignKey("CardUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.PayinRefund", b => + { + b.HasOne("Sheaft.Domain.Models.Payin", "Payin") + .WithMany("Refunds") + .HasForeignKey("PayinUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("Sheaft.Domain.Models.PurchaseOrder", "PurchaseOrder") + .WithMany() + .HasForeignKey("PurchaseOrderUid") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + }); + + modelBuilder.Entity("Sheaft.Domain.Models.Store", b => + { + b.OwnsMany("Sheaft.Domain.Models.TimeSlotHour", "OpeningHours", b1 => + { + b1.Property("StoreUid") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("Day") + .HasColumnType("int"); + + b1.Property("From") + .HasColumnType("time"); + + b1.Property("To") + .HasColumnType("time"); + + b1.HasKey("StoreUid", "Id"); + + b1.ToTable("StoreOpeningHours"); + + b1.WithOwner() + .HasForeignKey("StoreUid"); + }); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sheaft.Infrastructure.Persistence/Migrations/20201130203206_Remove_DeclarationRequired_Legal.cs b/Sheaft.Infrastructure.Persistence/Migrations/20201130203206_Remove_DeclarationRequired_Legal.cs new file mode 100644 index 000000000..5410b46be --- /dev/null +++ b/Sheaft.Infrastructure.Persistence/Migrations/20201130203206_Remove_DeclarationRequired_Legal.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Sheaft.Infrastructure.Persistence.Migrations +{ + public partial class Remove_DeclarationRequired_Legal : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "DeclarationRequired", + schema: "app", + table: "Legals"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "DeclarationRequired", + schema: "app", + table: "Legals", + type: "bit", + nullable: true); + } + } +} diff --git a/Sheaft.Infrastructure.Persistence/Migrations/AppDbContextModelSnapshot.cs b/Sheaft.Infrastructure.Persistence/Migrations/AppDbContextModelSnapshot.cs index 31cc5a6df..d63a84f4b 100644 --- a/Sheaft.Infrastructure.Persistence/Migrations/AppDbContextModelSnapshot.cs +++ b/Sheaft.Infrastructure.Persistence/Migrations/AppDbContextModelSnapshot.cs @@ -2062,9 +2062,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.HasBaseType("Sheaft.Domain.Models.Legal"); - b.Property("DeclarationRequired") - .HasColumnType("bit"); - b.Property("Email") .HasColumnType("nvarchar(max)"); diff --git a/Sheaft.Web.Manage/Controllers/DeclarationsController.cs b/Sheaft.Web.Manage/Controllers/DeclarationsController.cs index 661231e50..0036e6f68 100644 --- a/Sheaft.Web.Manage/Controllers/DeclarationsController.cs +++ b/Sheaft.Web.Manage/Controllers/DeclarationsController.cs @@ -43,34 +43,12 @@ public async Task Index(CancellationToken token, int page = 0, in if (take > 100) take = 100; - var legalIds = await _context.Legals + var entities = await _context.Legals .OfType() - .Get(c => c.DeclarationRequired && c.Declaration != null && c.Declaration.Status == DeclarationStatus.Validated) - .Select(c => c.Id) - .ToListAsync(token); - - var currentMonth = DateTimeOffset.UtcNow.Month; - var query = await _context.PurchaseOrders.Get(d => - d.Status >= PurchaseOrderStatus.Accepted - && d.Status < PurchaseOrderStatus.Refused) - .Where(d => d.CreatedOn.Month == currentMonth && !legalIds.Contains(d.Vendor.Id)) - .Select(d => new { d.Vendor, d.TotalOnSalePrice }) - .ToListAsync(token); - - var results = query.GroupBy(c => c.Vendor).Select(d => new ProducerRequiredDeclarationViewModel - { - Id = d.Key.Id, - Name = d.Key.Name, - Email = d.Key.Email, - Phone = d.Key.Phone, - Total = d.Sum(e => e.TotalOnSalePrice) - }).Where(d => d.Total > 100); - - var entities = results - .OrderByDescending(c => c.Total) + .OrderByDescending(c => c.CreatedOn) .Skip(page * take) .Take(take) - .ToList(); + .ToListAsync(token); ViewBag.Page = page; ViewBag.Take = take;