diff --git a/VichVich.BuildingBlocks.Application/Exceptions/CommandValidationException.cs b/VichVich.BuildingBlocks.Application/Exceptions/CommandValidationException.cs new file mode 100644 index 0000000..c1eb1b2 --- /dev/null +++ b/VichVich.BuildingBlocks.Application/Exceptions/CommandValidationException.cs @@ -0,0 +1,13 @@ +using FluentValidation.Results; + +namespace Vizhvizh.BuildingBlocks.Application.Exceptions; + +public class CommandValidationException : Exception +{ + public CommandValidationException(List errors) + { + Errors = errors; + } + + public List Errors { get; set; } +} diff --git a/VichVich.BuildingBlocks.Application/Validations/ValidationCommandHandlerDecorator.cs b/VichVich.BuildingBlocks.Application/Validations/ValidationCommandHandlerDecorator.cs new file mode 100644 index 0000000..6fc2c80 --- /dev/null +++ b/VichVich.BuildingBlocks.Application/Validations/ValidationCommandHandlerDecorator.cs @@ -0,0 +1,82 @@ +using FluentValidation; +using System.ComponentModel.DataAnnotations; +using Vizhvizh.BuildingBlocks.Application.Configuration.Commnad; +using Vizhvizh.BuildingBlocks.Application.Exceptions; +using Vizhvizh.BuildingBlocks.Domain.Contract; + +namespace Vizhvizh.BuildingBlocks.Application.Validations; + +public class ValidationCommandHandlerDecorator : ICommandHandler + where TCommand : ICommand +{ + private readonly ICommandHandler _decorated; + private readonly IEnumerable> _validators; + + public ValidationCommandHandlerDecorator( + ICommandHandler decorated, + IEnumerable> validators) + { + _decorated = decorated; + _validators = validators; + } + + public async Task Handle(TCommand command, CancellationToken cancellationToken) + { + if (_validators.Any()) + { + var context = new ValidationContext(command); + var validationResults = await Task.WhenAll( + _validators.Select(v => v.ValidateAsync(context, cancellationToken))); + + var failures = validationResults + .SelectMany(r => r.Errors) + .Where(f => f != null) + .ToList(); + + if (failures.Any()) + { + throw new CommandValidationException(failures); + } + } + + await _decorated.Handle(command, cancellationToken); + } +} + +// اگر Command شما خروجی دارد (ICommandHandler) +public class ValidationCommandHandlerDecorator : ICommandHandler + where TCommand : ICommand +{ + private readonly ICommandHandler _decorated; + private readonly IEnumerable> _validators; + + public ValidationCommandHandlerDecorator( + ICommandHandler decorated, + IEnumerable> validators) + { + _decorated = decorated; + _validators = validators; + } + + public async Task Handle(TCommand command, CancellationToken cancellationToken) + { + if (_validators.Any()) + { + var context = new ValidationContext(command); + var validationResults = await Task.WhenAll( + _validators.Select(v => v.ValidateAsync(context, cancellationToken))); + + var failures = validationResults + .SelectMany(r => r.Errors) + .Where(f => f != null) + .ToList(); + + if (failures.Any()) + { + throw new CommandValidationException(failures); + } + } + + return await _decorated.Handle(command, cancellationToken); + } +} diff --git a/VichVich.BuildingBlocks.Application/Vizhvizh.BuildingBlocks.Application.csproj b/VichVich.BuildingBlocks.Application/Vizhvizh.BuildingBlocks.Application.csproj index a24bee2..a646b64 100644 --- a/VichVich.BuildingBlocks.Application/Vizhvizh.BuildingBlocks.Application.csproj +++ b/VichVich.BuildingBlocks.Application/Vizhvizh.BuildingBlocks.Application.csproj @@ -6,6 +6,16 @@ enable + + + + + + + + + + diff --git a/VichVich.BuildingBlocks.Domain/Entity.cs b/VichVich.BuildingBlocks.Domain/Entity.cs index 12454ec..2551d38 100644 --- a/VichVich.BuildingBlocks.Domain/Entity.cs +++ b/VichVich.BuildingBlocks.Domain/Entity.cs @@ -11,6 +11,8 @@ public abstract class Entity CreateOn = DateTime.Now; } public T Id { get; protected set; } + public byte[] RowVersion { get; private set; } + public DateTime CreateOn { get; init ; } private List _domainEvents; diff --git a/VichVich.BuildingBlocks.Domain/IRepositoryBase.cs b/VichVich.BuildingBlocks.Domain/IRepositoryBase.cs index 16adb9a..53f9ddd 100644 --- a/VichVich.BuildingBlocks.Domain/IRepositoryBase.cs +++ b/VichVich.BuildingBlocks.Domain/IRepositoryBase.cs @@ -1,10 +1,12 @@ namespace Vizhvizh.BuildingBlocks.Domain; -public interface IRepositoryBase - where TDomain : Entity where TId : ITypeIdValueBase +public interface IRepositoryBase + where T : Entity where TId : ITypeIdValueBase { - Task CreateAsync(TDomain entity, CancellationToken cancellationToken = default); - Task UpdateAsync(TDomain entity, CancellationToken cancellationToken = default); - Task DeleteAsync(TId id, CancellationToken cancellationToken = default); - Task GetByIdAsync(TId id, CancellationToken cancellationToken = default); + Task AddAsync(T entity, CancellationToken cancellationToken); + Task UpdateAsync(T entity, CancellationToken cancellationToken); + Task DeleteAsync(TId id, CancellationToken cancellationToken); + Task DeleteAsync(T entity, CancellationToken cancellationToken); + Task FindByIdAsync(TId id, CancellationToken cancellationToken); + IQueryable GetQueryAsNoTracking(); } diff --git a/VichVich.BuildingBlocks.Infrastructure/EntityTypeConfigurationBase.cs b/VichVich.BuildingBlocks.Infrastructure/EntityTypeConfigurationBase.cs new file mode 100644 index 0000000..17d08c5 --- /dev/null +++ b/VichVich.BuildingBlocks.Infrastructure/EntityTypeConfigurationBase.cs @@ -0,0 +1,89 @@ +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Microsoft.EntityFrameworkCore; +using Vizhvizh.BuildingBlocks.Domain; + +public class BaseEntityConfiguration : IEntityTypeConfiguration + where T : Entity + where TId : TypedIdValueBase +{ + public virtual void Configure(EntityTypeBuilder builder) + { + // تنظیمات Id + ConfigureId(builder); + + // تنظیمات RowVersion + ConfigureRowVersion(builder); + + // تنظیمات CreateOn (اگر وجود داشته باشد) + ConfigureCreateOn(builder); + } + + private void ConfigureId(EntityTypeBuilder builder) + { + builder.HasKey(x => x.Id); + + if (typeof(TIdType) == typeof(int) || typeof(TIdType) == typeof(long)) + { + // ❌ مشکل: اینجا نمی‌توانیم به نام جدول دسترسی داشته باشیم + // builder.UseHiLo($"Sequence_{typeof(T).Name}") + + // ✅ راه‌حل: در اینجا فقط تنظیمات Id را انجام بده، Hi-Lo را بعداً اعمال کن + builder.Property(x => x.Id) + .HasConversion( + id => id.Value, + value => (TId)Activator.CreateInstance(typeof(TId), value)!) + .ValueGeneratedOnAdd(); + + // ❌ UseHiLo را اینجا نزنید، چون هنوز نام جدول مشخص نیست + } + else if (typeof(TIdType) == typeof(Guid)) + { + builder.Property(x => x.Id) + .HasConversion( + id => id.Value, + value => (TId)Activator.CreateInstance(typeof(TId), value)!) + .HasDefaultValueSql("NEWSEQUENTIALID()") + .ValueGeneratedOnAdd(); + } + else if (typeof(TIdType) == typeof(string)) + { + builder.Property(x => x.Id) + .HasConversion( + id => id.Value, + value => (TId)Activator.CreateInstance(typeof(TId), value)!) + .HasMaxLength(50); + } + } + private void ConfigureRowVersion(EntityTypeBuilder builder) + { + // بررسی وجود خاصیت RowVersion با Reflection + var hasRowVersion = typeof(T).GetProperty("RowVersion") != null; + + if (hasRowVersion) + { + // تنظیم RowVersion به عنوان Concurrency Token + builder.Property("RowVersion") + .IsRowVersion() // این یک خط همه کارها را می‌کند + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate(); + + // برای دیتابیس‌های مختلف: + // builder.Property("RowVersion").HasDefaultValueSql("rowversion"); + } + } + + private void ConfigureCreateOn(EntityTypeBuilder builder) + { + // تنظیم CreateOn (اگر وجود داشته باشد) + var hasCreateOn = typeof(T).GetProperty("CreateOn") != null; + + if (hasCreateOn) + { + builder.Property("CreateOn") + .HasDefaultValueSql("GETDATE()") // SQL Server + // برای PostgreSQL: .HasDefaultValueSql("CURRENT_TIMESTAMP") + // برای MySQL: .HasDefaultValueSql("CURRENT_TIMESTAMP") + .ValueGeneratedOnAdd(); + } + } +} \ No newline at end of file diff --git a/VichVich.BuildingBlocks.Infrastructure/Lifetimes/IScopeDependency.cs b/VichVich.BuildingBlocks.Infrastructure/Lifetimes/IScopeDependency.cs new file mode 100644 index 0000000..47af9e8 --- /dev/null +++ b/VichVich.BuildingBlocks.Infrastructure/Lifetimes/IScopeDependency.cs @@ -0,0 +1,5 @@ +namespace Vizhvizh.BuildingBlocks.Infrastructure.Lifetimes; + +public interface IScopeDependency +{ +} diff --git a/VichVich.BuildingBlocks.Infrastructure/Lifetimes/ISingletonDependency.cs b/VichVich.BuildingBlocks.Infrastructure/Lifetimes/ISingletonDependency.cs new file mode 100644 index 0000000..3eebe0b --- /dev/null +++ b/VichVich.BuildingBlocks.Infrastructure/Lifetimes/ISingletonDependency.cs @@ -0,0 +1,5 @@ +namespace Vizhvizh.BuildingBlocks.Infrastructure.Lifetimes; + +public interface ISingletonDependency +{ +} diff --git a/VichVich.BuildingBlocks.Infrastructure/Lifetimes/ITransientDependency.cs b/VichVich.BuildingBlocks.Infrastructure/Lifetimes/ITransientDependency.cs new file mode 100644 index 0000000..8c5b2d1 --- /dev/null +++ b/VichVich.BuildingBlocks.Infrastructure/Lifetimes/ITransientDependency.cs @@ -0,0 +1,5 @@ +namespace Vizhvizh.BuildingBlocks.Infrastructure.Lifetimes; + +public interface ITransientDependency +{ +} diff --git a/VichVich.BuildingBlocks.Infrastructure/ModelBuilderExtensions.cs b/VichVich.BuildingBlocks.Infrastructure/ModelBuilderExtensions.cs new file mode 100644 index 0000000..500faf0 --- /dev/null +++ b/VichVich.BuildingBlocks.Infrastructure/ModelBuilderExtensions.cs @@ -0,0 +1,117 @@ +using Microsoft.EntityFrameworkCore; +using Vizhvizh.BuildingBlocks.Domain; + +public static class ModelBuilderExtensions +{ + public static void AddHiLoSequences(this ModelBuilder modelBuilder) + { + var entityTypes = modelBuilder.Model.GetEntityTypes(); + + foreach (var entityType in entityTypes) + { + var primaryKey = entityType.FindPrimaryKey(); + if (primaryKey == null) continue; + + var keyProperty = primaryKey.Properties.FirstOrDefault(); + if (keyProperty == null) continue; + + // ✅ استخراج نوع واقعی از TypedIdValueBase + var actualKeyType = GetUnderlyingKeyType(keyProperty.ClrType); + + // فقط برای int و long + if (actualKeyType == typeof(int) || actualKeyType == typeof(long)) + { + var tableName = entityType.GetTableName(); + var sequenceName = GetSequenceName(tableName ?? entityType.Name); + var schema = entityType.GetSchema(); + + if (actualKeyType == typeof(int)) + { + modelBuilder.HasSequence(sequenceName, schema) + .StartsAt(1) + .IncrementsBy(1); + } + else if (actualKeyType == typeof(long)) + { + modelBuilder.HasSequence(sequenceName, schema) + .StartsAt(1) + .IncrementsBy(1); + } + + keyProperty.SetHiLoSequenceName(sequenceName); + } + + + } + } + + //public static void UseHiLoForEntities(this ModelBuilder modelBuilder) + //{ + // var entityTypes = modelBuilder.Model.GetEntityTypes(); + + // foreach (var entityType in entityTypes) + // { + // var primaryKey = entityType.FindPrimaryKey(); + // if (primaryKey == null) continue; + + // var keyProperty = primaryKey.Properties.FirstOrDefault(); + // if (keyProperty == null) continue; + + // // ✅ از همان متد استفاده کنید + // var actualKeyType = GetUnderlyingKeyType(keyProperty.ClrType); + + // if (actualKeyType == typeof(int) || actualKeyType == typeof(long)) + // { + // var tableName = entityType.GetTableName(); + // var sequenceName = GetSequenceName(tableName ?? entityType.Name); + + // // تنظیم Hi-Lo روی Property + // keyProperty.SetHiLoSequenceName(sequenceName); + // } + // } + //} + + /// + /// استخراج نوع اصلی از TypedIdValueBase + /// پشتیبانی از: + /// - TypedIdValueBase + /// - TypedIdValueBase + /// - CategoryId : TypedIdValueBase + /// + private static Type GetUnderlyingKeyType(Type keyType) + { + // حالت 1: خود keyType از نوع TypedIdValueBase باشد + if (keyType.IsGenericType && + keyType.GetGenericTypeDefinition() == typeof(TypedIdValueBase<>)) + { + return keyType.GetGenericArguments()[0]; + } + + // حالت 2: keyType از TypedIdValueBase ارث‌بری کرده باشد + var baseType = keyType.BaseType; + while (baseType != null && baseType != typeof(object)) + { + if (baseType.IsGenericType && + baseType.GetGenericTypeDefinition() == typeof(TypedIdValueBase<>)) + { + return baseType.GetGenericArguments()[0]; + } + baseType = baseType.BaseType; + } + + // حالت 3: خود keyType int یا long باشد + if (keyType == typeof(int) || keyType == typeof(long) || + keyType == typeof(int?) || keyType == typeof(long?)) + { + return Nullable.GetUnderlyingType(keyType) ?? keyType; + } + + // حالت 4: نوع دیگر (مثلاً Guid, string) + return keyType; + } + + private static string GetSequenceName(string tableName) + { + return $"Sequence_{tableName}"; + } +} \ No newline at end of file diff --git a/VichVich.BuildingBlocks.Infrastructure/Vizhvizh.BuildingBlocks.Infrastructure.csproj b/VichVich.BuildingBlocks.Infrastructure/Vizhvizh.BuildingBlocks.Infrastructure.csproj index 6ef520c..e01a0d4 100644 --- a/VichVich.BuildingBlocks.Infrastructure/Vizhvizh.BuildingBlocks.Infrastructure.csproj +++ b/VichVich.BuildingBlocks.Infrastructure/Vizhvizh.BuildingBlocks.Infrastructure.csproj @@ -6,14 +6,7 @@ enable - - - - - - - - + diff --git a/Vichvich.Shop.ApplicationContract/Vizhvizh.Shop.ApplicationContract.csproj b/Vichvich.Shop.ApplicationContract/Vizhvizh.Shop.ApplicationContract.csproj index fb2a893..7ad4eb8 100644 --- a/Vichvich.Shop.ApplicationContract/Vizhvizh.Shop.ApplicationContract.csproj +++ b/Vichvich.Shop.ApplicationContract/Vizhvizh.Shop.ApplicationContract.csproj @@ -1,19 +1,18 @@  - - net8.0 - enable - enable - + + net8.0 + enable + enable + - - - + + + - - - - - + + + + diff --git a/Vichvich.Shop.Domain/Products/Repositories/IProductRepository.cs b/Vichvich.Shop.Domain/Products/Repositories/IProductRepository.cs index f3826b0..faf4ad5 100644 --- a/Vichvich.Shop.Domain/Products/Repositories/IProductRepository.cs +++ b/Vichvich.Shop.Domain/Products/Repositories/IProductRepository.cs @@ -4,6 +4,6 @@ using Vizhvizh.BuildingBlocks.Domain; namespace Vizhvizh.Shop.Domain.Products.Repositories; -public interface IProductRepository : IRepositoryBase +public interface IProductRepository { } diff --git a/Vichvich.Shop.Domain/Shops/Repositories/IShopRepository.cs b/Vichvich.Shop.Domain/Shops/Repositories/IShopRepository.cs index 4ccdaf6..6ccf8b1 100644 --- a/Vichvich.Shop.Domain/Shops/Repositories/IShopRepository.cs +++ b/Vichvich.Shop.Domain/Shops/Repositories/IShopRepository.cs @@ -1,9 +1,8 @@ -using Vizhvizh.Shop.Domain.Shops.TypeIds; +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.Shop.Domain.Shops.TypeIds; namespace Vizhvizh.Shop.Domain.Shops.Repositories; -public interface IShopRepository +public interface IShopRepository : IRepositoryBase { - Task AddAsync(Entities.Shop shop, CancellationToken cancellationToken); - Task FindByIdAsync(ShopId id, CancellationToken cancellationToken); } diff --git a/Vichvich.Shop.Domain/Sliders/Repositories/ISliderRepository.cs b/Vichvich.Shop.Domain/Sliders/Repositories/ISliderRepository.cs index 00408df..de2b51c 100644 --- a/Vichvich.Shop.Domain/Sliders/Repositories/ISliderRepository.cs +++ b/Vichvich.Shop.Domain/Sliders/Repositories/ISliderRepository.cs @@ -1,10 +1,9 @@ -using Vizhvizh.Shop.Domain.Sliders.Entities; +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.Shop.Domain.Sliders.Entities; using Vizhvizh.Shop.Domain.Sliders.TypeIds; namespace Vizhvizh.Shop.Domain.Sliders.Repositories; -public interface ISliderRepository +public interface ISliderRepository : IRepositoryBase { - Task AddAsync(Slider slider, CancellationToken cancellationToken); - Task GetByIdAsync(SliderId id,CancellationToken cancellationToken); } diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/CategoryConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/CategoryConfiguration.cs index ce00f22..af981e0 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/CategoryConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/CategoryConfiguration.cs @@ -1,19 +1,18 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Vizhvizh.Shop.Domain.Products.Entities; +using Vizhvizh.Shop.Domain.Products.TypeIds; using Vizhvizh.Shop.Domain.Products.ValuesObjects; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -internal class CategoryConfiguration : IEntityTypeConfiguration +internal class CategoryConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); + builder.ToTable("Categories", schema: "Shop"); - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) - .HasConversion(x => x.Value, x => new Domain.Products.TypeIds.CategoryId(x)) - .ValueGeneratedOnAdd(); builder.Property(x => x.Title) .HasField("_title") @@ -39,6 +38,24 @@ internal class CategoryConfiguration : IEntityTypeConfiguration .HasConversion(x => x.Value, x => Domain.Products.ValuesObjects.CategoryPath.CreateNew(x)) .HasColumnType("HIERARCHYID"); + + // ایندکس برای Path با نوع HIERARCHYID + builder.HasIndex(x => x.Path) + .HasDatabaseName("IX_Categories_Path") + .IsClustered(false); // معمولاً برای HierarchyId بهتر است non-clustered باشد + + // رابطه خودارجاع برای ParentId + builder.HasOne() + .WithMany() + .HasForeignKey(x => x.ParentId) + .HasConstraintName("FK_Categories_ParentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(false); + + // ایندکس برای ParentId جهت بهبود performance در کوئری‌های سلسله مراتبی + builder.HasIndex(x => x.ParentId) + .HasDatabaseName("IX_Categories_ParentId"); + builder.Metadata.FindNavigation(nameof(Category.Products))? .SetPropertyAccessMode(PropertyAccessMode.Field); builder.Metadata.FindNavigation(nameof(Category.CategoryVariantUnits))? diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/CategoryVariantUnitConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/CategoryVariantUnitConfiguration.cs index efe2ae8..e2a24f6 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/CategoryVariantUnitConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/CategoryVariantUnitConfiguration.cs @@ -1,18 +1,17 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Vizhvizh.Shop.Domain.Products.Entities; +using Vizhvizh.Shop.Domain.Products.TypeIds; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -internal class CategoryVariantUnitConfiguration : IEntityTypeConfiguration +internal class CategoryVariantUnitConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); + builder.ToTable("CategoryVariantUnit", schema: "Shop"); - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) - .HasConversion(x => x.Value, x => new Domain.Products.TypeIds.CategoryVariantUnitId(x)) - .ValueGeneratedOnAdd(); builder.Property(x => x.VariantUnitId) .HasField("_variantUnitId") diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/ManagementConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/ManagementConfiguration.cs index 63e2420..5283342 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/ManagementConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/ManagementConfiguration.cs @@ -1,17 +1,17 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Vizhvizh.Shop.Domain.Shops.Entities; +using Vizhvizh.Shop.Domain.Shops.TypeIds; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -internal class ManagementConfiguration : IEntityTypeConfiguration +internal class ManagementConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); + builder.ToTable("Managements", schema: "Shop"); - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) - .HasConversion(x => x.Value, x => new Domain.Shops.TypeIds.ShopId(x)); builder.Metadata.FindNavigation(nameof(Management.Shop))? .SetPropertyAccessMode(PropertyAccessMode.Field); diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/MemberConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/MemberConfiguration.cs index d4fe072..00cf8e1 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/MemberConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/MemberConfiguration.cs @@ -1,18 +1,18 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Vizhvizh.Shop.Domain.Members.Entities; +using Vizhvizh.Shop.Domain.Members.TypeIds; using Vizhvizh.Shop.Domain.Members.ValuesObjects; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -internal class MemberConfiguration : IEntityTypeConfiguration +internal class MemberConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); + builder.ToTable("Members", schema: "Shop"); - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) - .ValueGeneratedOnAdd(); builder.Property(x => x.PhoneNumber) .HasField("_phoneNumber"); diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/ProductConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/ProductConfiguration.cs index 4446d99..5c3e571 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/ProductConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/ProductConfiguration.cs @@ -2,19 +2,19 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using System.Drawing; using Vizhvizh.Shop.Domain.Products.Entities; +using Vizhvizh.Shop.Domain.Products.TypeIds; using Vizhvizh.Shop.Domain.Products.ValuesObjects; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -internal class ProductConfiguration : IEntityTypeConfiguration +internal class ProductConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); + builder.ToTable("Products", schema: "Shop"); - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) - .HasConversion(x => x.Value, x => new Domain.Products.TypeIds.ProductId(x)) - .ValueGeneratedOnAdd(); builder.OwnsOne(x => x.ProductCondition, sa => { diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/ProductVariantConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/ProductVariantConfiguration.cs index c28403d..a15a67d 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/ProductVariantConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/ProductVariantConfiguration.cs @@ -1,19 +1,19 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Vizhvizh.Shop.Domain.Products.Entities; +using Vizhvizh.Shop.Domain.Products.TypeIds; using Vizhvizh.Shop.Domain.Products.ValuesObjects; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -internal class ProductVariantConfiguration : IEntityTypeConfiguration +internal class ProductVariantConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); + builder.ToTable("ProductVariants", schema: "Shop"); - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) - .HasConversion(x => x.Value, x => new Domain.Products.TypeIds.ProductVariantId(x)) - .ValueGeneratedOnAdd(); + builder.OwnsOne(x => x.Score, sa => { diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/ResourceConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/ResourceConfiguration.cs index 41b9686..bc0105f 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/ResourceConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/ResourceConfiguration.cs @@ -2,19 +2,18 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Vizhvizh.Shared.Domain.ValueObjects; using Vizhvizh.Shop.Domain.Users.Entities; +using Vizhvizh.Shop.Domain.Users.TypeIds; using Vizhvizh.Shop.Domain.Users.ValueObjects; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -public class ResourceConfiguration : IEntityTypeConfiguration +public class ResourceConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); builder.ToTable("Resources", schema: "Shop"); - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) - .HasConversion(x => x.Value, x => new Domain.Users.TypeIds.ResourceId(x)) - .ValueGeneratedOnAdd(); + builder.Property(x => x.Title) .HasField("_title"); @@ -23,10 +22,10 @@ public class ResourceConfiguration : IEntityTypeConfiguration builder.Property(x => x.ModuleName) .HasField("_moduleName") .HasColumnType("int") - .HasConversion(x=> (int)x.Value, x=> ModuleNameVO.CreateNew((ModuleNamesEnum)x)); + .HasConversion(x => (int)x.Value, x => ModuleNameVO.CreateNew((ModuleNamesEnum)x)); builder.Property(x => x.ResourceKey) - .HasConversion(x=>x.Value, x=> ResourceKey.CreateNew(x)) + .HasConversion(x => x.Value, x => ResourceKey.CreateNew(x)) .HasField("_resourceKey"); diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/RoleConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/RoleConfiguration.cs index a1c3c73..1c3a003 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/RoleConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/RoleConfiguration.cs @@ -1,18 +1,18 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Vizhvizh.Shop.Domain.Users.Entities; +using Vizhvizh.Shop.Domain.Users.TypeIds; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -public class RoleConfiguration : IEntityTypeConfiguration +public class RoleConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); + builder.ToTable("Roles", schema: "Shop"); - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) - .HasConversion(x => x.Value, x => new Domain.Users.TypeIds.RoleId(x)) - .ValueGeneratedOnAdd(); + builder.Property(x => x.Title) .HasField("_title"); diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/RoleResourceConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/RoleResourceConfiguration.cs index 0376986..c9a7946 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/RoleResourceConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/RoleResourceConfiguration.cs @@ -1,19 +1,18 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Vizhvizh.Shop.Domain.Users.Entities; +using Vizhvizh.Shop.Domain.Users.TypeIds; using Vizhvizh.Shop.Domain.Users.ValueObjects; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -public class RoleResourceConfiguration : IEntityTypeConfiguration +public class RoleResourceConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); + builder.ToTable("RoleResources", schema: "Shop"); - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) - .HasConversion(x => x.Value, x => new Domain.Users.TypeIds.RoleResourceId(x)) - .ValueGeneratedOnAdd(); builder.Property(x=>x.AccessLevel) .HasConversion(x=>x.Value, x=> AccessLevel.CreateNew((AccessLevelEnum)x)); diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/ShippingMethodConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/ShippingMethodConfiguration.cs index fffe466..7fa0cd0 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/ShippingMethodConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/ShippingMethodConfiguration.cs @@ -1,19 +1,18 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Vizhvizh.Shop.Domain.Shops.Entities; +using Vizhvizh.Shop.Domain.Shops.TypeIds; using Vizhvizh.Shop.Domain.Shops.ValuesObjects; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -internal class ShippingMethodConfiguration : IEntityTypeConfiguration +internal class ShippingMethodConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); + builder.ToTable("ShippingMethods", schema: "Shop"); - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) - .HasConversion(x => x.Value, x => new Domain.Shops.TypeIds.ShippingMethodId(x)) - .ValueGeneratedOnAdd(); builder.Property(x => x.Title) .HasField("_title"); diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/ShopConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/ShopConfiguration.cs index 9b02ff4..7065f49 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/ShopConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/ShopConfiguration.cs @@ -1,19 +1,18 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Vizhvizh.Shop.Domain.Shops.Entities; +using Vizhvizh.Shop.Domain.Shops.TypeIds; using Vizhvizh.Shop.Domain.Shops.ValuesObjects; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -public class ShopConfiguration : IEntityTypeConfiguration +public class ShopConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); builder.ToTable("Shops", schema: "Shop"); - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) - .HasConversion(x => x.Value, x => new Domain.Shops.TypeIds.ShopId(x)) - .ValueGeneratedOnAdd(); + builder.Property(x => x.OwnerId) .HasField("_ownerId"); diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/SliderConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/SliderConfiguration.cs index 78d12f5..ad8c274 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/SliderConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/SliderConfiguration.cs @@ -1,19 +1,18 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Vizhvizh.Shop.Domain.Sliders.Entities; +using Vizhvizh.Shop.Domain.Sliders.TypeIds; using Vizhvizh.Shop.Domain.Sliders.ValuesObjects; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -internal class SliderConfiguration : IEntityTypeConfiguration +internal class SliderConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); + builder.ToTable("Sliders", schema: "Shop"); - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) - .HasConversion(x => x.Value, x => new Domain.Sliders.TypeIds.SliderId(x)) - .ValueGeneratedOnAdd(); builder.Property(x => x.Title) .HasField("_title"); diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/SpecificationsConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/SpecificationsConfiguration.cs index a179b24..048e123 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/SpecificationsConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/SpecificationsConfiguration.cs @@ -2,18 +2,17 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Newtonsoft.Json; using Vizhvizh.Shop.Domain.Products.Entities; +using Vizhvizh.Shop.Domain.Products.TypeIds; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -internal class SpecificationsConfiguration : IEntityTypeConfiguration +internal class SpecificationsConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); + builder.ToTable("ProductSpecifications", schema: "Shop"); - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) - .HasConversion(x=>x.Value, x=> new Domain.Products.TypeIds.SpecificationsId(x)) - .ValueGeneratedOnAdd(); builder.Property(x => x.Title) .HasField("_title"); diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/UnitConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/UnitConfiguration.cs index deb404f..ccddc02 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/UnitConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/UnitConfiguration.cs @@ -1,17 +1,18 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Vizhvizh.Shop.Domain.Products.Entities; +using Vizhvizh.Shop.Domain.Products.TypeIds; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -internal class UnitConfiguration : IEntityTypeConfiguration +internal class UnitConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); + builder.ToTable("Units", schema: "Shop"); - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) - .HasConversion(x => x.Value, x => new Domain.Products.TypeIds.UnitId(x)); + builder.Property(x => x.Title) .HasField("_title"); diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/UserConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/UserConfiguration.cs index dd7e143..7dda122 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/UserConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/UserConfiguration.cs @@ -1,18 +1,18 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Vizhvizh.Shop.Domain.Users.Entities; +using Vizhvizh.Shop.Domain.Users.TypeIds; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -public class UserConfiguration : IEntityTypeConfiguration +public class UserConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); + builder.ToTable("Users", schema: "Shop"); - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) - .HasConversion(x => x.Value, x => new Domain.Users.TypeIds.UserId(x)) - .ValueGeneratedOnAdd(); + //builder.OwnsOne(x => x.NationalCode, sa => //{ diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/VariantConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/VariantConfiguration.cs index c4376f3..91e9746 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/VariantConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/VariantConfiguration.cs @@ -1,17 +1,18 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Vizhvizh.Shop.Domain.Products.Entities; +using Vizhvizh.Shop.Domain.Products.TypeIds; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -internal class VariantConfiguration : IEntityTypeConfiguration +internal class VariantConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); + builder.ToTable("Variants", schema: "Shop"); - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) - .HasConversion(x => x.Value, x => new Domain.Products.TypeIds.VariantId(x)); + builder.Property(x => x.Title) .HasField("_title"); diff --git a/Vichvich.Shop.Infrastructure/EF/Configurations/VariantUnitConfiguration.cs b/Vichvich.Shop.Infrastructure/EF/Configurations/VariantUnitConfiguration.cs index cb0dedf..2cdf848 100644 --- a/Vichvich.Shop.Infrastructure/EF/Configurations/VariantUnitConfiguration.cs +++ b/Vichvich.Shop.Infrastructure/EF/Configurations/VariantUnitConfiguration.cs @@ -1,17 +1,17 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Vizhvizh.Shop.Domain.Products.Entities; +using Vizhvizh.Shop.Domain.Products.TypeIds; namespace Vizhvizh.Shop.Infrastructure.EF.Configurations; -internal class VariantUnitConfiguration : IEntityTypeConfiguration +internal class VariantUnitConfiguration : BaseEntityConfiguration { - public void Configure(EntityTypeBuilder builder) + public override void Configure(EntityTypeBuilder builder) { + base.Configure(builder); + builder.ToTable("VariantUnits", schema: "Shop"); - builder.HasKey(x=>x.Id); - builder.Property(x => x.Id) - .HasConversion(x => x.Value, x => new Domain.Products.TypeIds.VariantUnitId(x)); builder.Property(x => x.VariantUnitType) .HasColumnType("INT") diff --git a/Vichvich.Shop.Infrastructure/EF/ShopDbContext.cs b/Vichvich.Shop.Infrastructure/EF/ShopDbContext.cs index 8a3a613..07e460a 100644 --- a/Vichvich.Shop.Infrastructure/EF/ShopDbContext.cs +++ b/Vichvich.Shop.Infrastructure/EF/ShopDbContext.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.IdentityModel.Abstractions; +using Vizhvizh.BuildingBlocks.Domain; using Vizhvizh.Shared.Domain.ValueObjects; using Vizhvizh.Shared.Infrastructure.EF.Configurations.Converters; using Vizhvizh.Shop.Domain.Members.TypeIds; @@ -36,15 +37,7 @@ internal class ShopDbContext : DbContext protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.ApplyConfigurationsFromAssembly(Assemblies.Infrastructure, FindConfigurations); - - foreach (var entityType in modelBuilder.Model.GetEntityTypes()) - { - var createOnProperty = entityType.FindProperty("CreateOn"); - if (createOnProperty != null && createOnProperty.ClrType == typeof(DateTime)) - { - createOnProperty.SetDefaultValueSql("GETDATE()"); - } - } + modelBuilder.AddHiLoSequences(); } public bool FindConfigurations(Type type) => type?.FullName?.Contains("Configurations") ?? false; diff --git a/Vichvich.Shop.Infrastructure/Exceptions/EntityNotFoundException.cs b/Vichvich.Shop.Infrastructure/Exceptions/EntityNotFoundException.cs new file mode 100644 index 0000000..2f33955 --- /dev/null +++ b/Vichvich.Shop.Infrastructure/Exceptions/EntityNotFoundException.cs @@ -0,0 +1,10 @@ +namespace Vizhvizh.Shop.Infrastructure.Exceptions; + +public class EntityNotFoundException : Exception +{ + public EntityNotFoundException() + : base("entity not found") + { + + } +} diff --git a/Vichvich.Shop.Infrastructure/Repositories/ShopRepository.cs b/Vichvich.Shop.Infrastructure/Repositories/ShopRepository.cs index fd63172..b2d2e18 100644 --- a/Vichvich.Shop.Infrastructure/Repositories/ShopRepository.cs +++ b/Vichvich.Shop.Infrastructure/Repositories/ShopRepository.cs @@ -1,15 +1,16 @@ -using Vizhvizh.Shop.Domain.Shops.Repositories; +using Vizhvizh.BuildingBlocks.Infrastructure.Lifetimes; +using Vizhvizh.Shop.Domain.Shops.Repositories; using Vizhvizh.Shop.Domain.Shops.TypeIds; using Vizhvizh.Shop.Infrastructure.EF; namespace Vizhvizh.Shop.Infrastructure.Repositories { - internal class ShopRepository(ShopDbContext context) : IShopRepository + internal class ShopRepository(ShopDbContext context) : RepositoryBase(context), IShopRepository, IScopeDependency { public async Task AddAsync(Domain.Shops.Entities.Shop shop, CancellationToken cancellationToken) => await context.Shops.AddAsync(shop, cancellationToken); public async Task FindByIdAsync(ShopId id, CancellationToken cancellationToken) - => await context.Shops.FindAsync(id,cancellationToken).ConfigureAwait(false); + => await context.Shops.FindAsync(id, cancellationToken).ConfigureAwait(false); } } diff --git a/Vichvich.Shop.Infrastructure/Repositories/SliderRepository.cs b/Vichvich.Shop.Infrastructure/Repositories/SliderRepository.cs index bf72fcc..fec1df3 100644 --- a/Vichvich.Shop.Infrastructure/Repositories/SliderRepository.cs +++ b/Vichvich.Shop.Infrastructure/Repositories/SliderRepository.cs @@ -1,18 +1,12 @@ -using Vizhvizh.Shop.Domain.Sliders.Entities; +using Vizhvizh.BuildingBlocks.Infrastructure.Lifetimes; +using Vizhvizh.Shop.Domain.Sliders.Entities; using Vizhvizh.Shop.Domain.Sliders.Repositories; using Vizhvizh.Shop.Domain.Sliders.TypeIds; +using Vizhvizh.Shop.Infrastructure.EF; namespace Vizhvizh.Shop.Infrastructure.Repositories; -public class SliderRepository : ISliderRepository +internal class SliderRepository(ShopDbContext context) : RepositoryBase(context), ISliderRepository, IScopeDependency { - public Task AddAsync(Slider slider, CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } - public Task GetByIdAsync(SliderId id, CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } } diff --git a/Vichvich.Shop.Infrastructure/RepositoryBase.cs b/Vichvich.Shop.Infrastructure/RepositoryBase.cs new file mode 100644 index 0000000..1d10bf8 --- /dev/null +++ b/Vichvich.Shop.Infrastructure/RepositoryBase.cs @@ -0,0 +1,52 @@ +using Microsoft.EntityFrameworkCore; +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.Shop.Infrastructure.EF; +using Vizhvizh.Shop.Infrastructure.Exceptions; + +namespace Vizhvizh.Shop.Infrastructure; + +internal class RepositoryBase : IRepositoryBase + where T : Entity where TId : ITypeIdValueBase +{ + private readonly ShopDbContext _shopDbContext; + + public RepositoryBase(ShopDbContext shopDbContext) + { + this._shopDbContext = shopDbContext; + } + public async Task AddAsync(T entity, CancellationToken cancellationToken) + { + await _shopDbContext.AddAsync(entity, cancellationToken); + } + + public async Task DeleteAsync(TId id, CancellationToken cancellationToken) + { + var entity = await FindByIdAsync(id, cancellationToken); + if (entity == null) + throw new EntityNotFoundException(); + + _shopDbContext.Remove(entity); + } + + public Task DeleteAsync(T entity, CancellationToken cancellationToken) + { + _shopDbContext.Remove(entity); + + return Task.CompletedTask; + } + + public async Task FindByIdAsync(TId id, CancellationToken cancellationToken) + { + var entity = _shopDbContext.Set(); + return await entity.FindAsync(id, cancellationToken); + } + + public IQueryable GetQueryAsNoTracking() + => _shopDbContext.Set().AsNoTracking(); + + public Task UpdateAsync(T entity, CancellationToken cancellationToken) + { + _shopDbContext.Update(entity); + return Task.CompletedTask; + } +} diff --git a/Vichvich.Shop.Infrastructure/ShopStartup.cs b/Vichvich.Shop.Infrastructure/ShopStartup.cs index 72ab06a..95f4d4e 100644 --- a/Vichvich.Shop.Infrastructure/ShopStartup.cs +++ b/Vichvich.Shop.Infrastructure/ShopStartup.cs @@ -15,6 +15,7 @@ using Vizhvizh.Shop.Infrastructure.Repositories; using Vizhvizh.BuildingBlocks.Infrastructure.SelectBuilders; using Vizhvizh.BuildingBlocks.Application.SelectBuilders; using Vizhvizh.Shop.Domain.Sliders.Repositories; +using Vizhvizh.BuildingBlocks.Infrastructure.Lifetimes; namespace Vizhvizh.Shop.Infrastructure; @@ -36,6 +37,7 @@ public class ShopStartup services.AddScoped(); services.Scan(scan => scan. FromAssemblies(Assemblies.Application, Assemblies.Infrastructure) + .AddClasses(classes => classes.AssignableTo(typeof(ICommandHandler<>)), publicOnly: false) .AsImplementedInterfaces() .WithScopedLifetime() @@ -47,7 +49,19 @@ public class ShopStartup .WithScopedLifetime() .AddClasses(classes => classes.AssignableTo(typeof(ICommandHandler<>)), publicOnly: false) .AsImplementedInterfaces() - .WithScopedLifetime()); + .WithScopedLifetime() + + .AddClasses(classes => classes.AssignableTo(typeof(ISingletonDependency)), publicOnly: false) + .AsImplementedInterfaces() + .WithSingletonLifetime() + .AddClasses(classes => classes.AssignableTo(typeof(IScopeDependency)), publicOnly: false) + .AsImplementedInterfaces() + .WithScopedLifetime() + .AddClasses(classes => classes.AssignableTo(typeof(ITransientDependency)), publicOnly: false) + .AsImplementedInterfaces() + .WithTransientLifetime() + + ); services.Decorate(typeof(ICommandHandler<>), typeof(UnitOfWorkCommandHandlerDecorator<>)); services.Decorate(typeof(ICommandHandler<,>), typeof(UnitOfWorkCommandHandlerDecorator<,>)); services.AddScoped(sa => @@ -71,10 +85,5 @@ public class ShopStartup services.AddScoped(); services.AddScoped(); - - #region Repositories - services.AddScoped(); - services.AddScoped(); - #endregion } } diff --git a/Vichvich.Shop.Infrastructure/Vizhvizh.Shop.Infrastructure.csproj b/Vichvich.Shop.Infrastructure/Vizhvizh.Shop.Infrastructure.csproj index d281444..1569351 100644 --- a/Vichvich.Shop.Infrastructure/Vizhvizh.Shop.Infrastructure.csproj +++ b/Vichvich.Shop.Infrastructure/Vizhvizh.Shop.Infrastructure.csproj @@ -19,7 +19,6 @@ - diff --git a/Vizhvizh.GoldGallery.Api/Configurations/ExecutionContextAccessor.cs b/Vizhvizh.GoldGallery.Api/Configurations/ExecutionContextAccessor.cs new file mode 100644 index 0000000..6fcd429 --- /dev/null +++ b/Vizhvizh.GoldGallery.Api/Configurations/ExecutionContextAccessor.cs @@ -0,0 +1,36 @@ +using Vizhvizh.BuildingBlocks.Application.Contract; + +namespace Vizhvizh.GoldGallery.Api.Configurations +{ + public class ExecutionContextAccessor : IExecutionContextAccessor + { + private readonly IHttpContextAccessor _httpContextAccessor; + + public ExecutionContextAccessor(IHttpContextAccessor httpContextAccessor) + { + _httpContextAccessor = httpContextAccessor; + } + + public Guid UserId + { + get + { + if (_httpContextAccessor + .HttpContext? + .User? + .Claims? + .SingleOrDefault(x => x.Type == "sub")? + .Value != null) + { + return Guid.Parse(_httpContextAccessor.HttpContext.User.Claims.Single( + x => x.Type == "sub").Value); + } + + throw new ApplicationException("User context is not available"); + } + } + + + public bool IsAvailable => _httpContextAccessor.HttpContext != null; + } +} diff --git a/Vizhvizh.GoldGallery.Api/Controllers/ProductController.cs b/Vizhvizh.GoldGallery.Api/Controllers/ProductController.cs new file mode 100644 index 0000000..7b0318b --- /dev/null +++ b/Vizhvizh.GoldGallery.Api/Controllers/ProductController.cs @@ -0,0 +1,17 @@ +using Microsoft.AspNetCore.Mvc; +using Vizhvizh.BuildingBlocks.Infrastructure; +using Vizhvizh.GoldGallery.ApplicationContract.Commands; + +namespace Vizhvizh.GoldGallery.Api.Controllers; + +[ApiController] +[Route("api/[controller]/[action]")] +public class ProductController(IExecutor executor) : ControllerBase +{ + [HttpPost] + public async Task Create([FromBody] CreateProductCommand request, CancellationToken cancellationToken) + { + await executor.Execute(request, cancellationToken); + return Ok(); + } +} diff --git a/Vizhvizh.GoldGallery.Api/Controllers/ShopController.cs b/Vizhvizh.GoldGallery.Api/Controllers/ShopController.cs new file mode 100644 index 0000000..8dfa75a --- /dev/null +++ b/Vizhvizh.GoldGallery.Api/Controllers/ShopController.cs @@ -0,0 +1,24 @@ +using Microsoft.AspNetCore.Mvc; +using Vizhvizh.BuildingBlocks.Infrastructure; +using Vizhvizh.GoldGallery.ApplicationContract.Commands; +using Vizhvizh.GoldGallery.ApplicationContract.DTOs; +using Vizhvizh.GoldGallery.ApplicationContract.Queries; + +namespace Vizhvizh.GoldGallery.Api.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class ShopController(IExecutor executor) : ControllerBase + { + [HttpGet] + public async Task> GetById([FromQuery] long shopId, CancellationToken cancellationToken) + => Ok(await executor.Execute(new GetShopByIdQuery(shopId), cancellationToken)); + + [HttpPost] + public async Task Create([FromBody] CreateShopCommand request, CancellationToken cancellationToken) + { + await executor.Execute(request, cancellationToken); + return Ok(); + } + } +} diff --git a/Vizhvizh.GoldGallery.Api/Controllers/SliderController.cs b/Vizhvizh.GoldGallery.Api/Controllers/SliderController.cs new file mode 100644 index 0000000..14de945 --- /dev/null +++ b/Vizhvizh.GoldGallery.Api/Controllers/SliderController.cs @@ -0,0 +1,45 @@ +using Microsoft.AspNetCore.Mvc; +using Vizhvizh.BuildingBlocks.Infrastructure; +using Vizhvizh.GoldGallery.Api.RequestModels; +using Vizhvizh.GoldGallery.ApplicationContract.Commands; +using Vizhvizh.GoldGallery.ApplicationContract.DTOs; +using Vizhvizh.GoldGallery.ApplicationContract.Queries; +using Vizhvizh.GoldGallery.Domain.Sliders.ValuesObjects; + +namespace Vizhvizh.GoldGallery.Api.Controllers +{ + + [Route("api/[controller]/[action]")] + [ApiController] + + public class SliderController(IExecutor executor) : ControllerBase + { + [HttpPost] + public async Task AddMainSlider([FromBody] CreateSliderRequestModel request, CancellationToken cancellationToken) + { + await executor.Execute(new CreateSliderCommand(request.Title, request.ImageUrl, request.LinkUrl, SliderKeyType.Main, null), cancellationToken); + return Ok(); + } + + [HttpPost] + public async Task AddShopSlider([FromHeader] long shopId, [FromBody] CreateSliderRequestModel request, CancellationToken cancellationToken) + { + await executor.Execute(new CreateSliderCommand(request.Title, request.ImageUrl, request.LinkUrl, SliderKeyType.Shop, shopId.ToString()), cancellationToken); + return Ok(); + } + + [HttpPost] + public async Task AddCategorySlider([FromHeader] long categoryId, [FromBody] CreateSliderRequestModel request, CancellationToken cancellationToken) + { + await executor.Execute(new CreateSliderCommand(request.Title, request.ImageUrl, request.LinkUrl, SliderKeyType.Category, categoryId.ToString()), cancellationToken); + return Ok(); + } + + [HttpGet] + public async Task>> GetByKey([FromQuery] GetSlidersByKeyQuery request,CancellationToken cancellationToken) + { + var result = await executor.Execute(request,cancellationToken); + return Ok(result); + } + } +} diff --git a/Vizhvizh.GoldGallery.Api/Program.cs b/Vizhvizh.GoldGallery.Api/Program.cs new file mode 100644 index 0000000..329c892 --- /dev/null +++ b/Vizhvizh.GoldGallery.Api/Program.cs @@ -0,0 +1,33 @@ +using Vizhvizh.BuildingBlocks.Application.Contract; +using Vizhvizh.GoldGallery.Api.Configurations; +using Vizhvizh.GoldGallery.Infrastructure; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + + +builder.Services.AddSingleton(); +builder.Services.AddSingleton(); + +GoldGalleryStartup.Initialize(builder.Services, builder.Configuration.GetConnectionString("GoldGallery")!); + +builder.Services.AddControllers(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +app.UseSwagger(); +app.UseSwaggerUI(opt => +{ + opt.SwaggerEndpoint("/swagger/v1/swagger.json", "v1"); +}); + +//app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/Vizhvizh.GoldGallery.Api/Properties/launchSettings.json b/Vizhvizh.GoldGallery.Api/Properties/launchSettings.json new file mode 100644 index 0000000..5c3de95 --- /dev/null +++ b/Vizhvizh.GoldGallery.Api/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:46206", + "sslPort": 44384 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "weatherforecast", + "applicationUrl": "http://localhost:5210", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "weatherforecast", + "applicationUrl": "https://localhost:7209;http://localhost:5210", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Vizhvizh.GoldGallery.Api/RequestModels/SliderRequestModels.cs b/Vizhvizh.GoldGallery.Api/RequestModels/SliderRequestModels.cs new file mode 100644 index 0000000..2b5c811 --- /dev/null +++ b/Vizhvizh.GoldGallery.Api/RequestModels/SliderRequestModels.cs @@ -0,0 +1,3 @@ +namespace Vizhvizh.GoldGallery.Api.RequestModels; + +public record CreateSliderRequestModel(string Title,string ImageUrl, string LinkUrl); diff --git a/Vizhvizh.GoldGallery.Api/Vizhvizh.GoldGallery.Api.csproj b/Vizhvizh.GoldGallery.Api/Vizhvizh.GoldGallery.Api.csproj new file mode 100644 index 0000000..5f2e959 --- /dev/null +++ b/Vizhvizh.GoldGallery.Api/Vizhvizh.GoldGallery.Api.csproj @@ -0,0 +1,21 @@ + + + + net8.0 + enable + enable + false + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + diff --git a/Vizhvizh.GoldGallery.Api/Vizhvizh.GoldGallery.Api.http b/Vizhvizh.GoldGallery.Api/Vizhvizh.GoldGallery.Api.http new file mode 100644 index 0000000..f903dda --- /dev/null +++ b/Vizhvizh.GoldGallery.Api/Vizhvizh.GoldGallery.Api.http @@ -0,0 +1,6 @@ +@Vizhvizh.GoldGallery.Api_HostAddress = http://localhost:5210 + +GET {{Vizhvizh.GoldGallery.Api_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/Vizhvizh.GoldGallery.Api/appsettings.Development.json b/Vizhvizh.GoldGallery.Api/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Vizhvizh.GoldGallery.Api/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Vizhvizh.GoldGallery.Api/appsettings.json b/Vizhvizh.GoldGallery.Api/appsettings.json new file mode 100644 index 0000000..bc5c3f2 --- /dev/null +++ b/Vizhvizh.GoldGallery.Api/appsettings.json @@ -0,0 +1,12 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "ConnectionStrings": { + "GoldGallery": "Data Source=.;Initial Catalog=Vizhvizh.GoldGallery;Integrated Security=True;Trusted_Connection=True; MultipleActiveResultSets=true;TrustServerCertificate=True;" + }, + "AllowedHosts": "*" +} diff --git a/Vizhvizh.GoldGallery.Application/CommandHandlers/Categories/CreateCategoryCommandHandler.cs b/Vizhvizh.GoldGallery.Application/CommandHandlers/Categories/CreateCategoryCommandHandler.cs new file mode 100644 index 0000000..0400dd9 --- /dev/null +++ b/Vizhvizh.GoldGallery.Application/CommandHandlers/Categories/CreateCategoryCommandHandler.cs @@ -0,0 +1,18 @@ +using Vizhvizh.BuildingBlocks.Application.Configuration.Commnad; +using Vizhvizh.GoldGallery.ApplicationContract.Commands; +using Vizhvizh.GoldGallery.Domain.Products.Entities; +using Vizhvizh.GoldGallery.Domain.Products.Repositories; + +namespace Vizhvizh.GoldGallery.Application.CommandHandlers.Categories; + +public class CreateCategoryCommandHandler(ICategoryRepository categoryRepository) : ICommandHandler +{ + public Task Handle(CreateCategoryCommand request, CancellationToken cancellationToken) + { + //var category = Category.CreateNew(request.Title, + // request.Description, + // request.Image) + + throw new Exception(); + } +} diff --git a/Vizhvizh.GoldGallery.Application/CommandHandlers/Products/CreateProductCommandHandler.cs b/Vizhvizh.GoldGallery.Application/CommandHandlers/Products/CreateProductCommandHandler.cs new file mode 100644 index 0000000..aa397b1 --- /dev/null +++ b/Vizhvizh.GoldGallery.Application/CommandHandlers/Products/CreateProductCommandHandler.cs @@ -0,0 +1,38 @@ +using FluentValidation; +using Microsoft.EntityFrameworkCore; +using Vizhvizh.BuildingBlocks.Application.Configuration.Commnad; +using Vizhvizh.GoldGallery.ApplicationContract.Commands; +using Vizhvizh.GoldGallery.Domain.Products.Entities; +using Vizhvizh.GoldGallery.Domain.Products.Repositories; +using Vizhvizh.GoldGallery.Domain.Resource.Products; + +namespace Vizhvizh.GoldGallery.Application.CommandHandlers.Products; + +public class CreateProductCommandHandler(IProductRepository productRepository, + ICategoryRepository categoryRepository) : ICommandHandler +{ + public async Task Handle(CreateProductCommand request, CancellationToken cancellationToken) + { + var category = (await categoryRepository.FindByIdAsync(request.CategoryId, cancellationToken))!; + var specifications = request.ProductSpecifications.Select(x => Specifications.CreateNew(x.Title, x.Values)).ToList(); + var productVariantImage = request.ProductVariants.Select(x => x.Gallery).ToList(); + var productVariants = request.ProductVariants.Select(x => ProductVariant.CreateNew(x.Quantity, x.Weight, x.Gallery)).ToList(); + + var product = Product.CreateNew(request.Title, request.Description, + request.ProductCondition, category, specifications, productVariants, request.Image, request.File3D, request.CraftsmanshipFee); + + await productRepository.AddAsync(product, cancellationToken); + } +} + +public class CreateProductCommandValidator : AbstractValidator +{ + public CreateProductCommandValidator(ICategoryRepository categoryRepository) + { + RuleFor(x => x.CategoryId) + .MustAsync(async (id, cancellation) => + { + return await categoryRepository.GetQueryAsNoTracking().AnyAsync(x => x.Id == id); + }).WithMessage(m => string.Format(ValidationResources.NotFoundCategoryById, m.CategoryId)); + } +} diff --git a/Vizhvizh.GoldGallery.Application/CommandHandlers/Shops/CreateShopCommandHandler.cs b/Vizhvizh.GoldGallery.Application/CommandHandlers/Shops/CreateShopCommandHandler.cs new file mode 100644 index 0000000..f86db9a --- /dev/null +++ b/Vizhvizh.GoldGallery.Application/CommandHandlers/Shops/CreateShopCommandHandler.cs @@ -0,0 +1,33 @@ +using Vizhvizh.BuildingBlocks.Application.Configuration.Commnad; +using Vizhvizh.Shared.Domain.ValueObjects; +using Vizhvizh.GoldGallery.ApplicationContract.Commands; +using Vizhvizh.GoldGallery.Domain.Shops.Repositories; +using Vizhvizh.GoldGallery.Domain.Shops.TypeIds; +using Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects; +using FluentValidation; + +namespace Vizhvizh.GoldGallery.Application.CommandHandlers.Shops; + +public class CreateShopCommandHandler(IShopRepository shopRepository) : ICommandHandler +{ + public async Task Handle(CreateShopCommand request, CancellationToken cancellationToken) + { + var location = ShopLocation.CreateNew(request.ShopLocation.Latitude, request.ShopLocation.Longitude, + request.ShopLocation.ProvinceId, request.ShopLocation.CityId, request.ShopLocation.Address, request.ShopLocation.PostalCode); + + var businessLicense = ShopBusinessLicense.CreateNew(request.ShopBusinessLicenseImage, request.ShopBusinessLicenseCode); + + var shop = Domain.Shops.Entities.Shop.CreateNew(request.OwnerId, request.Title, + location, TelephoneVO.CreateNew(request.Telephone), businessLicense, request.Description); + + await shopRepository.AddAsync(shop, cancellationToken); + } +} + +public class CreateShopCommandValidator : AbstractValidator +{ + public CreateShopCommandValidator() + { + + } +} \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Application/CommandHandlers/Shops/SetTitleShopCommandHandler.cs b/Vizhvizh.GoldGallery.Application/CommandHandlers/Shops/SetTitleShopCommandHandler.cs new file mode 100644 index 0000000..efac17b --- /dev/null +++ b/Vizhvizh.GoldGallery.Application/CommandHandlers/Shops/SetTitleShopCommandHandler.cs @@ -0,0 +1,14 @@ +using Vizhvizh.BuildingBlocks.Application.Configuration.Commnad; +using Vizhvizh.GoldGallery.ApplicationContract.Commands; +using Vizhvizh.GoldGallery.Domain.Shops.Repositories; + +namespace Vizhvizh.GoldGallery.Application.CommandHandlers.Shops; + +public class SetTitleShopCommandHandler(IShopRepository shopRepository) : ICommandHandler +{ + public async Task Handle(SetTitleShopCommand request, CancellationToken cancellationToken) + { + var shop = await shopRepository.FindByIdAsync(request.ShopId, cancellationToken); + shop.SetTitle(request.Title); + } +} diff --git a/Vizhvizh.GoldGallery.Application/CommandHandlers/Sliders/CreateSliderCommandHandler.cs b/Vizhvizh.GoldGallery.Application/CommandHandlers/Sliders/CreateSliderCommandHandler.cs new file mode 100644 index 0000000..1975b3d --- /dev/null +++ b/Vizhvizh.GoldGallery.Application/CommandHandlers/Sliders/CreateSliderCommandHandler.cs @@ -0,0 +1,18 @@ +using Vizhvizh.BuildingBlocks.Application.Configuration.Commnad; +using Vizhvizh.GoldGallery.ApplicationContract.Commands; +using Vizhvizh.GoldGallery.Domain.Sliders.Entities; +using Vizhvizh.GoldGallery.Domain.Sliders.Repositories; +using Vizhvizh.GoldGallery.Domain.Sliders.ValuesObjects; + +namespace Vizhvizh.GoldGallery.Application.CommandHandlers.Sliders; + +public class CreateSliderCommandHandler(ISliderRepository sliderRepository) : ICommandHandler +{ + public async Task Handle(CreateSliderCommand request, CancellationToken cancellationToken) + { + var slider = Slider.CreateNew(request.Title, SliderImage.CreateNew(request.ImageUrl), + SliderUrl.CreateNew(request.LinkUrl), new SliderKey(request.SliderKeyType, request.SliderKey)); + + await sliderRepository.AddAsync(slider, cancellationToken); + } +} diff --git a/Vizhvizh.GoldGallery.Application/CommandHandlers/TestCommandHandler.cs b/Vizhvizh.GoldGallery.Application/CommandHandlers/TestCommandHandler.cs new file mode 100644 index 0000000..0f77e35 --- /dev/null +++ b/Vizhvizh.GoldGallery.Application/CommandHandlers/TestCommandHandler.cs @@ -0,0 +1,22 @@ +using FluentValidation; +using Vizhvizh.BuildingBlocks.Application.Configuration.Commnad; +using Vizhvizh.GoldGallery.ApplicationContract.Commands; + +namespace Vizhvizh.GoldGallery.Application.CommandHandlers +{ + public class TestCommandHandler : ICommandHandler + { + public Task Handle(TestCommand request, CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } + } + + public class TestCommandValidator : AbstractValidator + { + public TestCommandValidator() + { + + } + } +} diff --git a/Vizhvizh.GoldGallery.Application/IGoldGalleryModule.cs b/Vizhvizh.GoldGallery.Application/IGoldGalleryModule.cs new file mode 100644 index 0000000..d74727a --- /dev/null +++ b/Vizhvizh.GoldGallery.Application/IGoldGalleryModule.cs @@ -0,0 +1,13 @@ +using Vizhvizh.BuildingBlocks.Application.Contract; +using Vizhvizh.BuildingBlocks.Domain.Contract; + +namespace Vizhvizh.GoldGallery.Application; + +public interface IGoldGalleryModule +{ + Task ExecuteCommandAsync(ICommand command,CancellationToken cancellationToken); + + Task ExecuteCommandAsync(ICommand command, CancellationToken cancellationToken); + + Task ExecuteQueryAsync(IQuery query, CancellationToken cancellationToken); +} diff --git a/Vizhvizh.GoldGallery.Application/QueryHandlers/Shops/GetShopByIdQueryHandler.cs b/Vizhvizh.GoldGallery.Application/QueryHandlers/Shops/GetShopByIdQueryHandler.cs new file mode 100644 index 0000000..7e4803f --- /dev/null +++ b/Vizhvizh.GoldGallery.Application/QueryHandlers/Shops/GetShopByIdQueryHandler.cs @@ -0,0 +1,33 @@ +using Dapper; +using Vizhvizh.BuildingBlocks.Application.Configuration.Query; +using Vizhvizh.BuildingBlocks.Application.Data; +using Vizhvizh.BuildingBlocks.Application.SelectBuilders; +using Vizhvizh.GoldGallery.ApplicationContract.DTOs; +using Vizhvizh.GoldGallery.ApplicationContract.Queries; + +namespace Vizhvizh.GoldGallery.Application.QueryHandlers.Shops; + +public class GetShopByIdQueryHandler(ISqlConnectionFactory connectionFactory, ISqlSelectBuilder sqlSelectBuilder) : IQueryHandler +{ + public async Task Handle(GetShopByIdQuery request, CancellationToken cancellationToken) + { + var connection = connectionFactory.GetOpenConnection(); + + var (sql, parameters) = sqlSelectBuilder + .From("Shop.Shops") + .Select( + (d => d.Id, dto => dto.Id), + (d => d.OwnerId, dto => dto.OwnerId), + (d => d.Title, dto => dto.Title), + (d => d.Description, dto => dto.Description), + (d => d.Email, dto => dto.Email), + (d => d.Telephone, dto => dto.Telephone), + (d => d.Logo, dto => dto.Logo) + ) + .Where(s => s.Id, request.ShopId) + .Build(); + + var result = await connection.QueryFirstOrDefaultAsync(sql, parameters); + return result; + } +} diff --git a/Vizhvizh.GoldGallery.Application/QueryHandlers/Sliders/GetSlidersByKeyQueryHandler.cs b/Vizhvizh.GoldGallery.Application/QueryHandlers/Sliders/GetSlidersByKeyQueryHandler.cs new file mode 100644 index 0000000..8c25807 --- /dev/null +++ b/Vizhvizh.GoldGallery.Application/QueryHandlers/Sliders/GetSlidersByKeyQueryHandler.cs @@ -0,0 +1,31 @@ +using Dapper; +using Vizhvizh.BuildingBlocks.Application.Configuration.Query; +using Vizhvizh.BuildingBlocks.Application.Data; +using Vizhvizh.BuildingBlocks.Application.SelectBuilders; +using Vizhvizh.GoldGallery.ApplicationContract.DTOs; +using Vizhvizh.GoldGallery.ApplicationContract.Queries; +using Vizhvizh.GoldGallery.Domain.Sliders.Entities; + +namespace Vizhvizh.GoldGallery.Application.QueryHandlers.Sliders; + +public class GetSlidersByKeyQueryHandler(ISqlConnectionFactory sqlConnectionFactory, ISqlSelectBuilder sqlSelectBuilder) + : IQueryHandler> +{ + public async Task> Handle(GetSlidersByKeyQuery request, CancellationToken cancellationToken) + { + var connection = sqlConnectionFactory.GetOpenConnection(); + + var (sql, parameters) = sqlSelectBuilder.From("Shop.Sliders") + .Select( + (d => d.Title, dto => dto.Title), + (d => d.Image, dto => dto.Image), + (d => d.Url, dto => dto.LinkUrl) + ) + .Pagination(request.PageNumber, request.PageSize, x => x.CreateOn, false) + .Where(x => x.Key, request.Key) + .Build(); + + var result = await connection.QueryAsync(sql, parameters); + return result; + } +} diff --git a/Vizhvizh.GoldGallery.Application/Vizhvizh.GoldGallery.Application.csproj b/Vizhvizh.GoldGallery.Application/Vizhvizh.GoldGallery.Application.csproj new file mode 100644 index 0000000..3640d10 --- /dev/null +++ b/Vizhvizh.GoldGallery.Application/Vizhvizh.GoldGallery.Application.csproj @@ -0,0 +1,15 @@ + + + + net8.0 + enable + enable + + + + + + + + + diff --git a/Vizhvizh.GoldGallery.ApplicationContract/Commands/CategoryCommands.cs b/Vizhvizh.GoldGallery.ApplicationContract/Commands/CategoryCommands.cs new file mode 100644 index 0000000..381b502 --- /dev/null +++ b/Vizhvizh.GoldGallery.ApplicationContract/Commands/CategoryCommands.cs @@ -0,0 +1,7 @@ +using Vizhvizh.BuildingBlocks.Domain.Contract; + +namespace Vizhvizh.GoldGallery.ApplicationContract.Commands; + +public record CreateCategoryCommand(string Title, string Description, string Image, long? ParentId) : CommandBase; +public record UpdateCategoryCommand(long CategoryId, string Title, string Description, string Image, long? ParentId) : CommandBase; +public record DeleteCategoryCommand(long CategoryId) : CommandBase; \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.ApplicationContract/Commands/ProductCommands.cs b/Vizhvizh.GoldGallery.ApplicationContract/Commands/ProductCommands.cs new file mode 100644 index 0000000..db04ac0 --- /dev/null +++ b/Vizhvizh.GoldGallery.ApplicationContract/Commands/ProductCommands.cs @@ -0,0 +1,9 @@ +using Vizhvizh.BuildingBlocks.Domain.Contract; +using Vizhvizh.GoldGallery.ApplicationContract.Models.Products; +using Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; + +namespace Vizhvizh.GoldGallery.ApplicationContract.Commands; + +public record CreateProductCommand(long ShopId, long CategoryId, string Title, string Description, string Image, decimal CraftsmanshipFee, + ProductConditionEnum ProductCondition, string? File3D, List ProductSpecifications, + List ProductVariants) : CommandBase; \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.ApplicationContract/Commands/ShopCommands.cs b/Vizhvizh.GoldGallery.ApplicationContract/Commands/ShopCommands.cs new file mode 100644 index 0000000..12b5e62 --- /dev/null +++ b/Vizhvizh.GoldGallery.ApplicationContract/Commands/ShopCommands.cs @@ -0,0 +1,9 @@ +using Vizhvizh.BuildingBlocks.Domain.Contract; +using Vizhvizh.GoldGallery.Domain.Shops.TypeIds; +using Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects; + +namespace Vizhvizh.GoldGallery.ApplicationContract.Commands; + +public record CreateShopCommand(long OwnerId, string Title,string Telephone,string ShopBusinessLicenseImage,string ShopBusinessLicenseCode, + string Description, string Email, ShopLocation ShopLocation) : CommandBase; +public record SetTitleShopCommand(long ShopId,string Title) : CommandBase; \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.ApplicationContract/Commands/SliderCommands.cs b/Vizhvizh.GoldGallery.ApplicationContract/Commands/SliderCommands.cs new file mode 100644 index 0000000..2c89dc8 --- /dev/null +++ b/Vizhvizh.GoldGallery.ApplicationContract/Commands/SliderCommands.cs @@ -0,0 +1,6 @@ +using Vizhvizh.BuildingBlocks.Domain.Contract; +using Vizhvizh.GoldGallery.Domain.Sliders.ValuesObjects; + +namespace Vizhvizh.GoldGallery.ApplicationContract.Commands; + +public record CreateSliderCommand(string Title, string ImageUrl,string LinkUrl, SliderKeyType SliderKeyType, string? SliderKey) : CommandBase; \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.ApplicationContract/Commands/TestCommands.cs b/Vizhvizh.GoldGallery.ApplicationContract/Commands/TestCommands.cs new file mode 100644 index 0000000..c3821af --- /dev/null +++ b/Vizhvizh.GoldGallery.ApplicationContract/Commands/TestCommands.cs @@ -0,0 +1,6 @@ +using Vizhvizh.BuildingBlocks.Domain.Contract; + +namespace Vizhvizh.GoldGallery.ApplicationContract.Commands +{ + public record TestCommand() : CommandBase; +} diff --git a/Vizhvizh.GoldGallery.ApplicationContract/DTOs/ShopDTO.cs b/Vizhvizh.GoldGallery.ApplicationContract/DTOs/ShopDTO.cs new file mode 100644 index 0000000..69c1e2e --- /dev/null +++ b/Vizhvizh.GoldGallery.ApplicationContract/DTOs/ShopDTO.cs @@ -0,0 +1,13 @@ +namespace Vizhvizh.GoldGallery.ApplicationContract.DTOs; + +public class ShopDTO +{ + public long Id { get; set; } + public long OwnerId{ get; set; } + public string Title { get; set; } = null!; + public string? Description{ get; set; } + public string? Email { get; set; } + public string Telephone { get; set; } = null!; + public string Logo{ get; set; } = null!; + public ShopLocationDTO ShopLocation { get; set; } = null!; +} diff --git a/Vizhvizh.GoldGallery.ApplicationContract/DTOs/ShopLocationDTO.cs b/Vizhvizh.GoldGallery.ApplicationContract/DTOs/ShopLocationDTO.cs new file mode 100644 index 0000000..d0c5814 --- /dev/null +++ b/Vizhvizh.GoldGallery.ApplicationContract/DTOs/ShopLocationDTO.cs @@ -0,0 +1,9 @@ +using Newtonsoft.Json; + +namespace Vizhvizh.GoldGallery.ApplicationContract.DTOs; + +public record ShopLocationDTO(double Latitude,double Longitude,int ProvinceId, int CityId,string Address, string PostalCode) +{ + public static implicit operator ShopLocationDTO(string address) + => JsonConvert.DeserializeObject(address)!; +} diff --git a/Vizhvizh.GoldGallery.ApplicationContract/DTOs/SliderDTO.cs b/Vizhvizh.GoldGallery.ApplicationContract/DTOs/SliderDTO.cs new file mode 100644 index 0000000..0b60a6e --- /dev/null +++ b/Vizhvizh.GoldGallery.ApplicationContract/DTOs/SliderDTO.cs @@ -0,0 +1,3 @@ +namespace Vizhvizh.GoldGallery.ApplicationContract.DTOs; + +public record SliderDTO(string Title, string Image,string LinkUrl); diff --git a/Vizhvizh.GoldGallery.ApplicationContract/Models/Products/CreateProductModel.cs b/Vizhvizh.GoldGallery.ApplicationContract/Models/Products/CreateProductModel.cs new file mode 100644 index 0000000..0de17e6 --- /dev/null +++ b/Vizhvizh.GoldGallery.ApplicationContract/Models/Products/CreateProductModel.cs @@ -0,0 +1,7 @@ +namespace Vizhvizh.GoldGallery.ApplicationContract.Models.Products; + +public class CreateProductModel +{ + public record SpecificationsModel(string Title, List Values); + public record ProductVariant(double Quantity, decimal Weight, List Gallery); +} diff --git a/Vizhvizh.GoldGallery.ApplicationContract/Queries/PaginationQuery.cs b/Vizhvizh.GoldGallery.ApplicationContract/Queries/PaginationQuery.cs new file mode 100644 index 0000000..35c0406 --- /dev/null +++ b/Vizhvizh.GoldGallery.ApplicationContract/Queries/PaginationQuery.cs @@ -0,0 +1,7 @@ +namespace Vizhvizh.GoldGallery.ApplicationContract.Queries; + +public class PaginationQuery +{ + public int PageNumber { get; set; } + public int PageSize { get; set; } +} diff --git a/Vizhvizh.GoldGallery.ApplicationContract/Queries/ShopQueries.cs b/Vizhvizh.GoldGallery.ApplicationContract/Queries/ShopQueries.cs new file mode 100644 index 0000000..e2abe41 --- /dev/null +++ b/Vizhvizh.GoldGallery.ApplicationContract/Queries/ShopQueries.cs @@ -0,0 +1,7 @@ +using Vizhvizh.BuildingBlocks.Domain.Contract; +using Vizhvizh.GoldGallery.ApplicationContract.DTOs; +using Vizhvizh.GoldGallery.Domain.Shops.TypeIds; + +namespace Vizhvizh.GoldGallery.ApplicationContract.Queries; + +public record GetShopByIdQuery(long ShopId) : IQuery; diff --git a/Vizhvizh.GoldGallery.ApplicationContract/Queries/SliderQueries.cs b/Vizhvizh.GoldGallery.ApplicationContract/Queries/SliderQueries.cs new file mode 100644 index 0000000..d71b4f9 --- /dev/null +++ b/Vizhvizh.GoldGallery.ApplicationContract/Queries/SliderQueries.cs @@ -0,0 +1,9 @@ +using Vizhvizh.BuildingBlocks.Domain.Contract; +using Vizhvizh.GoldGallery.ApplicationContract.DTOs; + +namespace Vizhvizh.GoldGallery.ApplicationContract.Queries; + +public class GetSlidersByKeyQuery : PaginationQuery, IQuery> +{ + public string Key { get; set; } +} diff --git a/Vizhvizh.GoldGallery.ApplicationContract/Vizhvizh.GoldGallery.ApplicationContract.csproj b/Vizhvizh.GoldGallery.ApplicationContract/Vizhvizh.GoldGallery.ApplicationContract.csproj new file mode 100644 index 0000000..c30e08a --- /dev/null +++ b/Vizhvizh.GoldGallery.ApplicationContract/Vizhvizh.GoldGallery.ApplicationContract.csproj @@ -0,0 +1,18 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + + diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Members/EntityResources.Designer.cs b/Vizhvizh.GoldGallery.Domain.Resource/Members/EntityResources.Designer.cs new file mode 100644 index 0000000..3b87837 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Members/EntityResources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Vizhvizh.GoldGallery.Domain.Resource.Members { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class EntityResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal EntityResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Vizhvizh.GoldGallery.Domain.Resource.Members.EntityResources", typeof(EntityResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Members/EntityResources.resx b/Vizhvizh.GoldGallery.Domain.Resource/Members/EntityResources.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Members/EntityResources.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Members/ExceptionResources.Designer.cs b/Vizhvizh.GoldGallery.Domain.Resource/Members/ExceptionResources.Designer.cs new file mode 100644 index 0000000..d5dc840 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Members/ExceptionResources.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Vizhvizh.GoldGallery.Domain.Resource.Members { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class ExceptionResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal ExceptionResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Vizhvizh.GoldGallery.Domain.Resource.Members.ExceptionResources", typeof(ExceptionResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to نام یا نام خانوادگی نمیتواند خالی باشد. + /// + public static string MemberFullNameNullOrEmptyException { + get { + return ResourceManager.GetString("MemberFullNameNullOrEmptyException", resourceCulture); + } + } + } +} diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Members/ExceptionResources.resx b/Vizhvizh.GoldGallery.Domain.Resource/Members/ExceptionResources.resx new file mode 100644 index 0000000..ed58c17 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Members/ExceptionResources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + نام یا نام خانوادگی نمیتواند خالی باشد + + \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Members/ValueObjectResources.Designer.cs b/Vizhvizh.GoldGallery.Domain.Resource/Members/ValueObjectResources.Designer.cs new file mode 100644 index 0000000..c8db852 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Members/ValueObjectResources.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Vizhvizh.GoldGallery.Domain.Resource.Members { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class ValueObjectResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal ValueObjectResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Vizhvizh.GoldGallery.Domain.Resource.Members.ValueObjectResources", typeof(ValueObjectResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to نام و نام خانوادگی. + /// + public static string MemberFullName { + get { + return ResourceManager.GetString("MemberFullName", resourceCulture); + } + } + } +} diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Members/ValueObjectResources.resx b/Vizhvizh.GoldGallery.Domain.Resource/Members/ValueObjectResources.resx new file mode 100644 index 0000000..7824784 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Members/ValueObjectResources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + نام و نام خانوادگی + + \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Products/EntityResources.Designer.cs b/Vizhvizh.GoldGallery.Domain.Resource/Products/EntityResources.Designer.cs new file mode 100644 index 0000000..1ffb9af --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Products/EntityResources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Vizhvizh.GoldGallery.Domain.Resource.Products { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class EntityResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal EntityResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Vizhvizh.GoldGallery.Domain.Resource.Products.EntityResources", typeof(EntityResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Products/EntityResources.resx b/Vizhvizh.GoldGallery.Domain.Resource/Products/EntityResources.resx new file mode 100644 index 0000000..4fdb1b6 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Products/EntityResources.resx @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Products/ExceptionResources.Designer.cs b/Vizhvizh.GoldGallery.Domain.Resource/Products/ExceptionResources.Designer.cs new file mode 100644 index 0000000..cd45be1 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Products/ExceptionResources.Designer.cs @@ -0,0 +1,99 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Vizhvizh.GoldGallery.Domain.Resource.Products { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class ExceptionResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal ExceptionResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Vizhvizh.GoldGallery.Domain.Resource.Products.ExceptionResources", typeof(ExceptionResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to اجرت نمی‌تواند منفی باشد. + /// + public static string CraftsmanshipFeeCannotBeNegativeException { + get { + return ResourceManager.GetString("CraftsmanshipFeeCannotBeNegativeException", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to وزن طلا باید بزرگتر از {0} گرم باشد. + /// + public static string GoldWeightMustGreaterThanException { + get { + return ResourceManager.GetString("GoldWeightMustGreaterThanException", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to اجرت نامعتبر می‌باشد. + /// + public static string InvalidCraftsmanshipFeeException { + get { + return ResourceManager.GetString("InvalidCraftsmanshipFeeException", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to مقدار {0} برای ویژگی با نوع {1} معتبر نمی‌باشد. + /// + public static string InvalidProductVariantValueException { + get { + return ResourceManager.GetString("InvalidProductVariantValueException", resourceCulture); + } + } + } +} diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Products/ExceptionResources.resx b/Vizhvizh.GoldGallery.Domain.Resource/Products/ExceptionResources.resx new file mode 100644 index 0000000..4d0b1b8 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Products/ExceptionResources.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + اجرت نمی‌تواند منفی باشد + + + وزن طلا باید بزرگتر از {0} گرم باشد + + + اجرت نامعتبر می‌باشد + + + مقدار {0} برای ویژگی با نوع {1} معتبر نمی‌باشد + + \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Products/ValidationResources.Designer.cs b/Vizhvizh.GoldGallery.Domain.Resource/Products/ValidationResources.Designer.cs new file mode 100644 index 0000000..69443fa --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Products/ValidationResources.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Vizhvizh.GoldGallery.Domain.Resource.Products { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class ValidationResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal ValidationResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Vizhvizh.GoldGallery.Domain.Resource.Products.ValidationResources", typeof(ValidationResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to دسته‌بندی با شناسه {0} یافت نشد. + /// + public static string NotFoundCategoryById { + get { + return ResourceManager.GetString("NotFoundCategoryById", resourceCulture); + } + } + } +} diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Products/ValidationResources.resx b/Vizhvizh.GoldGallery.Domain.Resource/Products/ValidationResources.resx new file mode 100644 index 0000000..b9392bc --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Products/ValidationResources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + دسته‌بندی با شناسه {0} یافت نشد + + \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Products/ValueObjectResources.Designer.cs b/Vizhvizh.GoldGallery.Domain.Resource/Products/ValueObjectResources.Designer.cs new file mode 100644 index 0000000..d2948d1 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Products/ValueObjectResources.Designer.cs @@ -0,0 +1,90 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Vizhvizh.GoldGallery.Domain.Resource.Products { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class ValueObjectResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal ValueObjectResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Vizhvizh.GoldGallery.Domain.Resource.Products.ValueObjectResources", typeof(ValueObjectResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to نو. + /// + public static string ProductConditionEnum_BrandNew { + get { + return ResourceManager.GetString("ProductConditionEnum_BrandNew", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to در حد نو. + /// + public static string ProductConditionEnum_LikeNew { + get { + return ResourceManager.GetString("ProductConditionEnum_LikeNew", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to کارکرده. + /// + public static string ProductConditionEnum_Used { + get { + return ResourceManager.GetString("ProductConditionEnum_Used", resourceCulture); + } + } + } +} diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Products/ValueObjectResources.resx b/Vizhvizh.GoldGallery.Domain.Resource/Products/ValueObjectResources.resx new file mode 100644 index 0000000..1af7d35 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Products/ValueObjectResources.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + نو + + + در حد نو + + + کارکرده + + \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Shops/EntityResources.Designer.cs b/Vizhvizh.GoldGallery.Domain.Resource/Shops/EntityResources.Designer.cs new file mode 100644 index 0000000..a8b23fb --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Shops/EntityResources.Designer.cs @@ -0,0 +1,99 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Vizhvizh.GoldGallery.Domain.Resource.Shops { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class EntityResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal EntityResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Vizhvizh.GoldGallery.Domain.Resource.Shops.EntityResources", typeof(EntityResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to مدیریت فروشگاه. + /// + public static string Management { + get { + return ResourceManager.GetString("Management", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to عضو. + /// + public static string Member { + get { + return ResourceManager.GetString("Member", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to نوع ارسال مرسوله. + /// + public static string ShippingMethod { + get { + return ResourceManager.GetString("ShippingMethod", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to فروشگاه. + /// + public static string Shop { + get { + return ResourceManager.GetString("Shop", resourceCulture); + } + } + } +} diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Shops/EntityResources.resx b/Vizhvizh.GoldGallery.Domain.Resource/Shops/EntityResources.resx new file mode 100644 index 0000000..55ceb56 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Shops/EntityResources.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + مدیریت فروشگاه + + + عضو + + + نوع ارسال مرسوله + + + فروشگاه + + \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Shops/ExceptionResources.Designer.cs b/Vizhvizh.GoldGallery.Domain.Resource/Shops/ExceptionResources.Designer.cs new file mode 100644 index 0000000..51c67b3 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Shops/ExceptionResources.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Vizhvizh.GoldGallery.Domain.Resource.Shops { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class ExceptionResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal ExceptionResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Vizhvizh.GoldGallery.Domain.Resource.Shops.ExceptionResources", typeof(ExceptionResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to آدرس اینترنتی اسلایدر نمیتواند خالی باشد. + /// + public static string IsNullOrEmptySliderUrlException { + get { + return ResourceManager.GetString("IsNullOrEmptySliderUrlException", resourceCulture); + } + } + } +} diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Shops/ExceptionResources.resx b/Vizhvizh.GoldGallery.Domain.Resource/Shops/ExceptionResources.resx new file mode 100644 index 0000000..1881bac --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Shops/ExceptionResources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + آدرس اینترنتی اسلایدر نمیتواند خالی باشد + + \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Shops/ValueObjectResources.Designer.cs b/Vizhvizh.GoldGallery.Domain.Resource/Shops/ValueObjectResources.Designer.cs new file mode 100644 index 0000000..b6d73f0 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Shops/ValueObjectResources.Designer.cs @@ -0,0 +1,81 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Vizhvizh.GoldGallery.Domain.Resource.Shops { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class ValueObjectResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal ValueObjectResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Vizhvizh.GoldGallery.Domain.Resource.Shops.ValueObjectResources", typeof(ValueObjectResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to نام و نام خانوادگی. + /// + public static string MemberFullName { + get { + return ResourceManager.GetString("MemberFullName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to لوکیشین فروشگاه. + /// + public static string ShopLocation { + get { + return ResourceManager.GetString("ShopLocation", resourceCulture); + } + } + } +} diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Shops/ValueObjectResources.resx b/Vizhvizh.GoldGallery.Domain.Resource/Shops/ValueObjectResources.resx new file mode 100644 index 0000000..c19287e --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Shops/ValueObjectResources.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + نام و نام خانوادگی + + + لوکیشین فروشگاه + + \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Users/EntityResources.Designer.cs b/Vizhvizh.GoldGallery.Domain.Resource/Users/EntityResources.Designer.cs new file mode 100644 index 0000000..c953e0d --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Users/EntityResources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Vizhvizh.GoldGallery.Domain.Resource.Users { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class EntityResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal EntityResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Vizhvizh.GoldGallery.Domain.Resource.Users.EntityResources", typeof(EntityResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Users/EntityResources.resx b/Vizhvizh.GoldGallery.Domain.Resource/Users/EntityResources.resx new file mode 100644 index 0000000..4fdb1b6 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Users/EntityResources.resx @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Users/ExceptionResources.Designer.cs b/Vizhvizh.GoldGallery.Domain.Resource/Users/ExceptionResources.Designer.cs new file mode 100644 index 0000000..508cb3a --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Users/ExceptionResources.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Vizhvizh.GoldGallery.Domain.Resource.Users { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class ExceptionResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal ExceptionResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Vizhvizh.GoldGallery.Domain.Resource.Users.ExceptionResources", typeof(ExceptionResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to کد ملی معتبر نمی باشد. + /// + public static string InvalidNationalCodeException { + get { + return ResourceManager.GetString("InvalidNationalCodeException", resourceCulture); + } + } + } +} diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Users/ExceptionResources.resx b/Vizhvizh.GoldGallery.Domain.Resource/Users/ExceptionResources.resx new file mode 100644 index 0000000..cc7357c --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Users/ExceptionResources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + کد ملی معتبر نمی باشد + + \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Users/ValueObjectResources.Designer.cs b/Vizhvizh.GoldGallery.Domain.Resource/Users/ValueObjectResources.Designer.cs new file mode 100644 index 0000000..3761e92 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Users/ValueObjectResources.Designer.cs @@ -0,0 +1,90 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Vizhvizh.GoldGallery.Domain.Resource.Users { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class ValueObjectResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal ValueObjectResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Vizhvizh.GoldGallery.Domain.Resource.Users.ValueObjectResources", typeof(ValueObjectResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to خواندن. + /// + public static string AccessLevelEnum_Read { + get { + return ResourceManager.GetString("AccessLevelEnum_Read", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to خواندن/نوشتن. + /// + public static string AccessLevelEnum_ReadWrite { + get { + return ResourceManager.GetString("AccessLevelEnum_ReadWrite", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to نوشتن. + /// + public static string AccessLevelEnum_Write { + get { + return ResourceManager.GetString("AccessLevelEnum_Write", resourceCulture); + } + } + } +} diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Users/ValueObjectResources.resx b/Vizhvizh.GoldGallery.Domain.Resource/Users/ValueObjectResources.resx new file mode 100644 index 0000000..7b26589 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Users/ValueObjectResources.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + خواندن + + + خواندن/نوشتن + + + نوشتن + + \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Domain.Resource/Vizhvizh.GoldGallery.Domain.Resource.csproj b/Vizhvizh.GoldGallery.Domain.Resource/Vizhvizh.GoldGallery.Domain.Resource.csproj new file mode 100644 index 0000000..cbcabd8 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain.Resource/Vizhvizh.GoldGallery.Domain.Resource.csproj @@ -0,0 +1,132 @@ + + + + net8.0 + enable + enable + + + + + EntityResources.resx + True + True + + + ExceptionResources.resx + True + True + + + ValueObjectResources.resx + True + True + + + EntityResources.resx + True + True + + + ExceptionResources.resx + True + True + + + True + True + ValidationResources.resx + + + ValueObjectResources.resx + True + True + + + EntityResources.resx + True + True + + + ExceptionResources.resx + True + True + + + ValueObjectResources.resx + True + True + + + EntityResources.resx + True + True + + + ExceptionResources.resx + True + True + + + ValueObjectResources.resx + True + True + + + + + + EntityResources.Designer.cs + PublicResXFileCodeGenerator + + + ExceptionResources.Designer.cs + PublicResXFileCodeGenerator + + + ValueObjectResources.Designer.cs + PublicResXFileCodeGenerator + + + EntityResources.Designer.cs + PublicResXFileCodeGenerator + + + ExceptionResources.Designer.cs + PublicResXFileCodeGenerator + + + PublicResXFileCodeGenerator + ValidationResources.Designer.cs + + + ValueObjectResources.Designer.cs + PublicResXFileCodeGenerator + + + EntityResources.Designer.cs + PublicResXFileCodeGenerator + + + ExceptionResources.Designer.cs + PublicResXFileCodeGenerator + + + ValueObjectResources.Designer.cs + PublicResXFileCodeGenerator + + + EntityResources.Designer.cs + PublicResXFileCodeGenerator + + + ExceptionResources.Designer.cs + PublicResXFileCodeGenerator + + + ValueObjectResources.Designer.cs + PublicResXFileCodeGenerator + + + + diff --git a/Vizhvizh.GoldGallery.Domain/Members/Entities/Member.cs b/Vizhvizh.GoldGallery.Domain/Members/Entities/Member.cs new file mode 100644 index 0000000..93c7ce7 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Members/Entities/Member.cs @@ -0,0 +1,41 @@ +using Vizhvizh.Shared.Domain.ValueObjects; +using Vizhvizh.GoldGallery.Domain.Members.TypeIds; +using Vizhvizh.GoldGallery.Domain.Members.ValuesObjects; +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.GoldGallery.Domain.Members.Events; + +namespace Vizhvizh.GoldGallery.Domain.Members.Entities; + +public class Member : Entity, IAggregateRoot +{ + private PhoneNumberVO _phoneNumber; + private MemberFullName _fullName; + private MemberAvatar? _avatar; + private MemberNationalCode? _nationalCode; + + private Member() + { + + } + private Member(PhoneNumberVO phoneNumber, MemberFullName fullName, MemberAvatar? avatar) + { + _fullName = fullName; + _phoneNumber = phoneNumber; + _avatar = avatar; + } + public static Member CreateNew(PhoneNumberVO phoneNumber, MemberFullName fullName, MemberAvatar? avatar = null) + { + return new Member(phoneNumber, fullName, avatar); + } + public MemberFullName? FullName => _fullName; + public PhoneNumberVO PhoneNumber => _phoneNumber; + public MemberAvatar? Avatar => _avatar; + public MemberNationalCode? NationalCode => _nationalCode; + + public void SetNationalCode(MemberNationalCode nationalCode) + { + _nationalCode = nationalCode; + this.AddDomainEvent(new SetNationalCodeEvent(this)); + } + +} diff --git a/Vizhvizh.GoldGallery.Domain/Members/Events/SetNationalCodeEvent.cs b/Vizhvizh.GoldGallery.Domain/Members/Events/SetNationalCodeEvent.cs new file mode 100644 index 0000000..c7607ea --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Members/Events/SetNationalCodeEvent.cs @@ -0,0 +1,9 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.GoldGallery.Domain.Members.Entities; + +namespace Vizhvizh.GoldGallery.Domain.Members.Events; + +public class SetNationalCodeEvent(Member member) : DomainEventBase +{ + public Member Member => member; +} diff --git a/Vizhvizh.GoldGallery.Domain/Members/Exceptions/MemberFullNameNullOrEmptyException.cs b/Vizhvizh.GoldGallery.Domain/Members/Exceptions/MemberFullNameNullOrEmptyException.cs new file mode 100644 index 0000000..b5d2cec --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Members/Exceptions/MemberFullNameNullOrEmptyException.cs @@ -0,0 +1,11 @@ +using Vizhvizh.GoldGallery.Domain.Resource.Members; +using Vizhvizh.BuildingBlocks.Domain.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Members.Exceptions; + +public class MemberFullNameNullOrEmptyException : ValueObjectValidationException +{ + public MemberFullNameNullOrEmptyException() : base(ExceptionResources.MemberFullNameNullOrEmptyException) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Members/TypeIds/MemberId.cs b/Vizhvizh.GoldGallery.Domain/Members/TypeIds/MemberId.cs new file mode 100644 index 0000000..3788937 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Members/TypeIds/MemberId.cs @@ -0,0 +1,16 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Members.TypeIds; + +public class MemberId : TypedIdValueBase +{ + public MemberId(long value) : base(value) + { + } + + public static implicit operator MemberId(long value) + => new MemberId(value); + + public static implicit operator long(MemberId value) + => value.Value; +} diff --git a/Vizhvizh.GoldGallery.Domain/Members/ValuesObjects/MemberAvatar.cs b/Vizhvizh.GoldGallery.Domain/Members/ValuesObjects/MemberAvatar.cs new file mode 100644 index 0000000..1678539 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Members/ValuesObjects/MemberAvatar.cs @@ -0,0 +1,17 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.Shared.Domain.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Members.ValuesObjects; + +public class MemberAvatar : ValueObject +{ + public const short Limit = 150; + public MemberAvatar(string value) + { + if (value.Length > Limit) + throw new CharacterLimitException(nameof(MemberAvatar), Limit); + + Value = value; + } + public string Value { get; init; } +} diff --git a/Vizhvizh.GoldGallery.Domain/Members/ValuesObjects/MemberFullName.cs b/Vizhvizh.GoldGallery.Domain/Members/ValuesObjects/MemberFullName.cs new file mode 100644 index 0000000..1dcd817 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Members/ValuesObjects/MemberFullName.cs @@ -0,0 +1,30 @@ +using Vizhvizh.Shared.Domain.Exceptions; +using Vizhvizh.GoldGallery.Domain.Members.Exceptions; +using Vizhvizh.GoldGallery.Domain.Resource.Members; +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Members.ValuesObjects; + +public class MemberFullName : ValueObject +{ + public const short FirstNameLimit = 50; + public const short LastNameLimit = 50; + public MemberFullName(string firstName, string lastName) + { + if (string.IsNullOrWhiteSpace(firstName) || string.IsNullOrWhiteSpace(lastName)) + throw new MemberFullNameNullOrEmptyException(); + + if (firstName.Length > FirstNameLimit || lastName.Length > LastNameLimit) + throw new CharacterLimitException(ValueObjectResources.MemberFullName, FirstNameLimit + LastNameLimit); + + FirstName = firstName; + LastName = lastName; + } + public string FirstName { get; init; } + public string LastName { get; init; } + + public override string ToString() + { + return $"{FirstName} {LastName}"; + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Members/ValuesObjects/MemberNationalCode.cs b/Vizhvizh.GoldGallery.Domain/Members/ValuesObjects/MemberNationalCode.cs new file mode 100644 index 0000000..73ee0a5 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Members/ValuesObjects/MemberNationalCode.cs @@ -0,0 +1,17 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.Shared.Domain.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Members.ValuesObjects; + +public class MemberNationalCode : ValueObject +{ + public const short Limit = 10; + public MemberNationalCode(string value) + { + if (value.Length > Limit) + throw new CharacterLimitException(nameof(MemberNationalCode), Limit); + + Value = value; + } + public string Value { get; private set; } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/Entities/Category.cs b/Vizhvizh.GoldGallery.Domain/Products/Entities/Category.cs new file mode 100644 index 0000000..2538edf --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/Entities/Category.cs @@ -0,0 +1,61 @@ +using Vizhvizh.Shared.Domain.ValueObjects; +using Vizhvizh.GoldGallery.Domain.Products.TypeIds; +using Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; +using Vizhvizh.BuildingBlocks.Domain; +using System.IO; + +namespace Vizhvizh.GoldGallery.Domain.Products.Entities; + +/// +/// دسته بندی +/// +public class Category : Entity +{ + private TitleVO _title; + private DescriptionVO _description; + private CategoryImage _image; + private CategoryId? _parentId; + private CategoryPath _path; + + #region Relationships + private List _products; + #endregion + + private Category() + { + + } + private Category(TitleVO title, + DescriptionVO description, + CategoryImage image, + CategoryPath path, + CategoryId? parentId = null, + CategoryPath? parentPath = null) + { + _title = title; + _description = description; + _image = image; + _parentId = parentId; + //_path = CategoryPath.CreatePath(parentPath, ; + + } + + public static Category CreateNew(TitleVO title, + DescriptionVO description, + CategoryImage image, + CategoryPath path, + CategoryId? parentId = null, + CategoryPath? parentPath = null) + { + return new Category(title, description, image, path, parentId, parentPath); + } + + public TitleVO Title => _title; + public DescriptionVO Description => _description; + public CategoryImage Image => _image; + public CategoryId? ParentId => _parentId; + public CategoryPath Path => _path; + public IReadOnlyList Products => _products; + + +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/Entities/Product.cs b/Vizhvizh.GoldGallery.Domain/Products/Entities/Product.cs new file mode 100644 index 0000000..c1ffa8c --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/Entities/Product.cs @@ -0,0 +1,80 @@ +using Vizhvizh.Shared.Domain.ValueObjects; +using Vizhvizh.GoldGallery.Domain.Products.TypeIds; +using Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; +using Vizhvizh.BuildingBlocks.Domain; + + +namespace Vizhvizh.GoldGallery.Domain.Products.Entities; + +/// +/// محصول +/// +public class Product : Entity, IAggregateRoot +{ + private Category _category; + private List _specifications; + + private ProductCondition _productCondition; + private TitleVO _title; + private DescriptionVO _description; + private ProductScore _score; + private CraftsmanshipFee _craftsmanshipFee; + private List _variants; + /// + ///عکس اصلی + /// + private ProductImage _image; + private ProductFile3D? _file3D; + + private Product() + { + + } + private Product(TitleVO title, + DescriptionVO description, + ProductCondition productCondition, + Category category, + List specifications, + List variants, + ProductImage image, + ProductFile3D? file3D, + CraftsmanshipFee craftsmanshipFee + ) + { + _title = title; + _description = description; + _productCondition = productCondition; + _category = category; + _category = category; + _specifications = specifications; + _variants = variants; + _image = image; + _file3D = file3D; + _craftsmanshipFee = craftsmanshipFee; + } + + public static Product CreateNew(TitleVO title, + DescriptionVO description, + ProductCondition productCondition, + Category category, + List specifications, + List variants, + ProductImage image, + ProductFile3D? file3D, + CraftsmanshipFee craftsmanshipFee) + { + return new(title, description, productCondition, category, specifications, variants, image, file3D, craftsmanshipFee); + } + + public Category Category => _category; + public ProductCondition ProductCondition => _productCondition; + public TitleVO Title => _title; + public DescriptionVO Description => _description; + public ProductScore Score => _score; + public ProductImage Image => _image; + public ProductFile3D? File3D => _file3D; + public CraftsmanshipFee CraftsmanshipFee => _craftsmanshipFee; + public IReadOnlyList Variants => _variants; + public IReadOnlyList Specifications => _specifications; + +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/Entities/ProductVariant.cs b/Vizhvizh.GoldGallery.Domain/Products/Entities/ProductVariant.cs new file mode 100644 index 0000000..98e5f6e --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/Entities/ProductVariant.cs @@ -0,0 +1,38 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.GoldGallery.Domain.Products.TypeIds; +using Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; + +namespace Vizhvizh.GoldGallery.Domain.Products.Entities; + +public class ProductVariant : Entity +{ + private ProductScore _score; + private ProductQuantity _quantity; + private ProductVariantGallery _gallery; + + private GoldWeight _weight; + + #region Relationships + private Product _product; + #endregion + private ProductVariant() + { + + } + private ProductVariant(ProductQuantity quantity, GoldWeight weight, ProductVariantGallery gallery) + { + _quantity = quantity; + _weight = weight; + _gallery = gallery; + } + + public ProductScore Score => _score; + public ProductQuantity Quantity => _quantity; + public GoldWeight Weight => _weight; + public Product Product => _product; + public ProductVariantGallery Gallery => _gallery; + + public static ProductVariant CreateNew(ProductQuantity quantity, GoldWeight weight, ProductVariantGallery gallery) + => new(quantity, weight, gallery); +} + diff --git a/Vizhvizh.GoldGallery.Domain/Products/Entities/Specifications.cs b/Vizhvizh.GoldGallery.Domain/Products/Entities/Specifications.cs new file mode 100644 index 0000000..da8299c --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/Entities/Specifications.cs @@ -0,0 +1,35 @@ +using Vizhvizh.Shared.Domain.ValueObjects; +using Vizhvizh.GoldGallery.Domain.Products.TypeIds; +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Products.Entities; + +/// +/// مشخصات محصول +/// +public class Specifications : Entity +{ + private TitleVO _title; + + private List _itemValues; + + #region RelationShips + private Product _product; + private Specifications() + { + + } + #endregion + private Specifications(TitleVO title, List itemValues) + { + _title = title; + _itemValues = itemValues; + } + + public static Specifications CreateNew(TitleVO title, List values) + => new Specifications(title, values); + + public TitleVO Title => _title; + public Product Product => _product; + public IReadOnlyList ItemValues => _itemValues; +} \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Domain/Products/Exceptions/CraftsmanshipFeeCannotBeNegativeException.cs b/Vizhvizh.GoldGallery.Domain/Products/Exceptions/CraftsmanshipFeeCannotBeNegativeException.cs new file mode 100644 index 0000000..e8e0d3c --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/Exceptions/CraftsmanshipFeeCannotBeNegativeException.cs @@ -0,0 +1,11 @@ +using Vizhvizh.BuildingBlocks.Domain.Exceptions; +using Vizhvizh.GoldGallery.Domain.Resource.Products; + +namespace Vizhvizh.GoldGallery.Domain.Products.Exceptions; + +public class CraftsmanshipFeeCannotBeNegativeException : ValueObjectValidationException +{ + public CraftsmanshipFeeCannotBeNegativeException() : base(ExceptionResources.CraftsmanshipFeeCannotBeNegativeException) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/Exceptions/GoldWeightMustGreaterThanException.cs b/Vizhvizh.GoldGallery.Domain/Products/Exceptions/GoldWeightMustGreaterThanException.cs new file mode 100644 index 0000000..d38b5ca --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/Exceptions/GoldWeightMustGreaterThanException.cs @@ -0,0 +1,12 @@ +using Vizhvizh.BuildingBlocks.Domain.Exceptions; +using Vizhvizh.GoldGallery.Domain.Resource.Products; + +namespace Vizhvizh.GoldGallery.Domain.Products.Exceptions; + +public class GoldWeightMustGreaterThanException : ValueObjectValidationException +{ + public GoldWeightMustGreaterThanException(short weight) + : base(string.Format(ExceptionResources.GoldWeightMustGreaterThanException, weight)) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/Exceptions/InvalidCraftsmanshipFeeException.cs b/Vizhvizh.GoldGallery.Domain/Products/Exceptions/InvalidCraftsmanshipFeeException.cs new file mode 100644 index 0000000..5685a2e --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/Exceptions/InvalidCraftsmanshipFeeException.cs @@ -0,0 +1,11 @@ +using Vizhvizh.BuildingBlocks.Domain.Exceptions; +using Vizhvizh.GoldGallery.Domain.Resource.Products; + +namespace Vizhvizh.GoldGallery.Domain.Products.Exceptions; + +public class InvalidCraftsmanshipFeeException : ValueObjectValidationException +{ + public InvalidCraftsmanshipFeeException() : base(ExceptionResources.InvalidCraftsmanshipFeeException) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/Exceptions/InvalidProductVariantValueException.cs b/Vizhvizh.GoldGallery.Domain/Products/Exceptions/InvalidProductVariantValueException.cs new file mode 100644 index 0000000..ef2d14e --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/Exceptions/InvalidProductVariantValueException.cs @@ -0,0 +1,14 @@ +using Vizhvizh.BuildingBlocks.Domain.Exceptions; +using Vizhvizh.GoldGallery.Domain.Resource.Products; + +namespace Vizhvizh.GoldGallery.Domain.Products.Exceptions +{ + public class InvalidProductVariantValueException : ValueObjectValidationException + { + public InvalidProductVariantValueException(string value, string typeName) + : base(string.Format(ExceptionResources.InvalidProductVariantValueException, value, typeName)) + { + + } + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/Repositories/ICategoryRepository.cs b/Vizhvizh.GoldGallery.Domain/Products/Repositories/ICategoryRepository.cs new file mode 100644 index 0000000..64beb0a --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/Repositories/ICategoryRepository.cs @@ -0,0 +1,9 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.GoldGallery.Domain.Products.Entities; +using Vizhvizh.GoldGallery.Domain.Products.TypeIds; + +namespace Vizhvizh.GoldGallery.Domain.Products.Repositories; + +public interface ICategoryRepository : IRepositoryBase +{ +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/Repositories/IProductRepository.cs b/Vizhvizh.GoldGallery.Domain/Products/Repositories/IProductRepository.cs new file mode 100644 index 0000000..0924803 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/Repositories/IProductRepository.cs @@ -0,0 +1,9 @@ +using Vizhvizh.GoldGallery.Domain.Products.Entities; +using Vizhvizh.GoldGallery.Domain.Products.TypeIds; +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Products.Repositories; + +public interface IProductRepository : IRepositoryBase +{ +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/TypeIds/CategoryId.cs b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/CategoryId.cs new file mode 100644 index 0000000..156a766 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/CategoryId.cs @@ -0,0 +1,19 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Products.TypeIds; + +/// +/// +/// +public class CategoryId : TypedIdValueBase +{ + public CategoryId(long value) : base(value) + { + } + + public static implicit operator CategoryId(long value) + => new CategoryId(value); + + public static implicit operator long(CategoryId value) + => value.Value; +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/TypeIds/CategoryVariantUnitId.cs b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/CategoryVariantUnitId.cs new file mode 100644 index 0000000..99a430e --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/CategoryVariantUnitId.cs @@ -0,0 +1,10 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Products.TypeIds; + +public class CategoryVariantUnitId : TypedIdValueBase +{ + public CategoryVariantUnitId(long value) : base(value) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/TypeIds/ModelId.cs b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/ModelId.cs new file mode 100644 index 0000000..1d7f008 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/ModelId.cs @@ -0,0 +1,10 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Products.TypeIds; + +public class ModelId : TypedIdValueBase +{ + public ModelId(long value) : base(value) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/TypeIds/ProductId.cs b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/ProductId.cs new file mode 100644 index 0000000..db56cd1 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/ProductId.cs @@ -0,0 +1,10 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Products.TypeIds; + +public class ProductId : TypedIdValueBase +{ + public ProductId(long value) : base(value) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/TypeIds/ProductVariantId.cs b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/ProductVariantId.cs new file mode 100644 index 0000000..2775e23 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/ProductVariantId.cs @@ -0,0 +1,10 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Products.TypeIds; + +public class ProductVariantId : TypedIdValueBase +{ + public ProductVariantId(long value) : base(value) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/TypeIds/SpecificationsId.cs b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/SpecificationsId.cs new file mode 100644 index 0000000..ad22c71 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/SpecificationsId.cs @@ -0,0 +1,10 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Products.TypeIds; + +public class SpecificationsId : TypedIdValueBase +{ + public SpecificationsId(long value) : base(value) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/TypeIds/UnitId.cs b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/UnitId.cs new file mode 100644 index 0000000..19544f8 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/UnitId.cs @@ -0,0 +1,10 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Products.TypeIds; + +public class UnitId : TypedIdValueBase +{ + public UnitId(long value) : base(value) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/TypeIds/VariantId.cs b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/VariantId.cs new file mode 100644 index 0000000..a661853 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/VariantId.cs @@ -0,0 +1,10 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Products.TypeIds; + +public class VariantId : TypedIdValueBase +{ + public VariantId(long value) : base(value) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/TypeIds/VariantUnitId.cs b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/VariantUnitId.cs new file mode 100644 index 0000000..43367a0 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/TypeIds/VariantUnitId.cs @@ -0,0 +1,10 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Products.TypeIds; + +public class VariantUnitId : TypedIdValueBase +{ + public VariantUnitId(long value) : base(value) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/CategoryImage.cs b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/CategoryImage.cs new file mode 100644 index 0000000..fccb9bb --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/CategoryImage.cs @@ -0,0 +1,20 @@ + +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.Shared.Domain.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; +public class CategoryImage : ValueObject +{ + public const short Limit = 150; + private CategoryImage(string value) + { + if (value.Length > Limit) + throw new CharacterLimitException(nameof(CategoryImage), Limit); + + Value = value; + } + public static CategoryImage CreateNew(string value) + => new CategoryImage(value); + + public string Value { get; init; } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/CategoryPath.cs b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/CategoryPath.cs new file mode 100644 index 0000000..219a61d --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/CategoryPath.cs @@ -0,0 +1,24 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; + +public class CategoryPath : ValueObject +{ + private CategoryPath(string value) + { + + Value = value; + } + public string Value { get; private set; } + public static CategoryPath CreateNew(string value) + => new CategoryPath(value); + + + public static CategoryPath CreatePath(CategoryPath? parentPath, string childId) + { + if (parentPath == null) + return new CategoryPath(childId); + + return new CategoryPath($"{parentPath.Value}/{childId}"); + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/CraftsmanshipFee.cs b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/CraftsmanshipFee.cs new file mode 100644 index 0000000..dd9f17e --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/CraftsmanshipFee.cs @@ -0,0 +1,57 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.GoldGallery.Domain.Products.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; + +/// +/// اجرت +/// +public class CraftsmanshipFee : ValueObject +{ + private const int TotalPrecision = 4; // Precision (P) + private const int DecimalScale = 2; // Scale (S) + private const int IntegerPartMaxDigits = TotalPrecision - DecimalScale; // = 2 + + private const decimal MaxValue = 99.99m; + private const decimal MinValue = 0m; + + public decimal Value { get; private set; } + + public CraftsmanshipFee(decimal value) + { + if (value < 0) + throw new CraftsmanshipFeeCannotBeNegativeException(); + if (!ValidateDecimalPrecision(value)) + throw new InvalidCraftsmanshipFeeException(); + + Value = value; + } + + public static CraftsmanshipFee CreateNew(decimal value) + => new CraftsmanshipFee(value); + + private bool ValidateDecimalPrecision(decimal value) + { + // روش اول: بررسی محدوده عددی + if (value > MaxValue || value < MinValue) + return false; + + // روش دوم: بررسی دقیق تعداد ارقام (اختیاری - برای اطمینان بیشتر) + var roundedValue = Math.Round(value, DecimalScale); + if (Math.Abs(value - roundedValue) > 0) + return false; + + // روش سوم: بررسی اینکه تعداد ارقام صحیح از حد مجاز بیشتر نباشد + var integerPart = Math.Floor(Math.Abs(value)); + if (integerPart >= (decimal)Math.Pow(10, IntegerPartMaxDigits)) + return false; + + return true; + } + + public static implicit operator CraftsmanshipFee(decimal value) + => new(value); + + public static implicit operator decimal(CraftsmanshipFee value) + => value.Value; +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/GoldWeight.cs b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/GoldWeight.cs new file mode 100644 index 0000000..60b768d --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/GoldWeight.cs @@ -0,0 +1,28 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.GoldGallery.Domain.Products.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; + +public class GoldWeight : ValueObject +{ + public decimal Value { get; private set; } // بر حسب گرم + + private GoldWeight(decimal value) + { + if (value <= 0) + throw new GoldWeightMustGreaterThanException(0); + + Value = value; + } + + public static GoldWeight CreateNew(decimal value) + => new(value); + + public static implicit operator GoldWeight(decimal value) + => new(value); + + public static implicit operator decimal(GoldWeight value) + => value.Value; + + +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/MoneyValue.cs b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/MoneyValue.cs new file mode 100644 index 0000000..10113e4 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/MoneyValue.cs @@ -0,0 +1,34 @@ +using Vizhvizh.Shared.Domain.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; + +/// +/// پول +/// +public class MoneyValue +{ + public const short CurrencyLimit = 150; + + public decimal Value { get; } + + public string Currency { get; } + + public static MoneyValue CreateNew(decimal value, string currency) + { + return new MoneyValue(value, currency); + } + + private MoneyValue(decimal value, string currency) + { + if(currency.Length > CurrencyLimit) + throw new CharacterLimitException(nameof(Currency), CurrencyLimit); + + this.Value = value; + this.Currency = currency; + } + + public static MoneyValue operator *(int left, MoneyValue right) + { + return new MoneyValue(right.Value * left, right.Currency); + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductCondition.cs b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductCondition.cs new file mode 100644 index 0000000..c6bdc57 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductCondition.cs @@ -0,0 +1,35 @@ +using System.ComponentModel.DataAnnotations; +using Vizhvizh.GoldGallery.Domain.Resource.Products; +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; + +/// +/// وضعیت محصول نو، کارکرده +/// +public class ProductCondition : ValueObject +{ + private ProductCondition(ProductConditionEnum value) + { + Value = value; + } + public static ProductCondition CreateNew(ProductConditionEnum value) + => new ProductCondition(value); + + public ProductConditionEnum Value { get; private set; } + + public static implicit operator ProductCondition(ProductConditionEnum value) + => new(value); + + public static implicit operator ProductConditionEnum(ProductCondition value) + => value.Value; +} +public enum ProductConditionEnum +{ + [Display(Name = nameof(ValueObjectResources.ProductConditionEnum_BrandNew), ResourceType = typeof(ValueObjectResources))] + BrandNew = 0, + [Display(Name = nameof(ValueObjectResources.ProductConditionEnum_LikeNew), ResourceType = typeof(ValueObjectResources))] + LikeNew = 1, + [Display(Name = nameof(ValueObjectResources.ProductConditionEnum_Used), ResourceType = typeof(ValueObjectResources))] + Used = 2, +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductFile3D.cs b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductFile3D.cs new file mode 100644 index 0000000..290217a --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductFile3D.cs @@ -0,0 +1,27 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.Shared.Domain.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; + +public class ProductFile3D : ValueObject +{ + public const short Limit = 150; + public string Value { get; private set; } + private ProductFile3D(string value) + { + if (value.Length > Limit) + throw new CharacterLimitException(nameof(ProductFile3D), Limit); + + Value = value; + } + + public static ProductFile3D CreateNew(string value) + => new(value); + + public static implicit operator ProductFile3D?(string? value) + => string.IsNullOrWhiteSpace(value) ? null : new(value); + + public static implicit operator string(ProductFile3D value) + => value.Value; + +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductImage.cs b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductImage.cs new file mode 100644 index 0000000..ee86ee7 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductImage.cs @@ -0,0 +1,29 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.Shared.Domain.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; + +/// +/// عکس محصولات +/// +public class ProductImage : ValueObject +{ + public const short Limit = 150; + private ProductImage(string value) + { + if (value.Length > Limit) + throw new CharacterLimitException(nameof(ProductImage), Limit); + + Value = value; + } + public static ProductImage CreateNew(string value) + => new ProductImage(value); + + public string Value { get; private set; } + + public static implicit operator ProductImage(string value) + => new(value); + + public static implicit operator string(ProductImage value) + => value.Value; +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductQuantity.cs b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductQuantity.cs new file mode 100644 index 0000000..eafa723 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductQuantity.cs @@ -0,0 +1,24 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; +/// +/// تعداد +/// +public class ProductQuantity : ValueObject +{ + private ProductQuantity(double value) + { + Value = value; + } + + public static ProductQuantity CreateNew(double value) + => new ProductQuantity(value); + + public double Value { get; init; } + + public static implicit operator ProductQuantity(double value) + => new(value); + + public static implicit operator double(ProductQuantity value) + => value.Value; +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductScore.cs b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductScore.cs new file mode 100644 index 0000000..e196cef --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductScore.cs @@ -0,0 +1,20 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; + +/// +/// امتیاز +/// +public class ProductScore : ValueObject +{ + private ProductScore(byte score, int totalVoters) + { + Score = score; + TotalVoters = totalVoters; + } + public static ProductScore CreateNew(byte score, int totalVoters) + => new ProductScore(score, totalVoters); + + public byte Score { get; private set; } + public int TotalVoters { get; private set; } +} diff --git a/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductVariantGallery.cs b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductVariantGallery.cs new file mode 100644 index 0000000..2677a57 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Products/ValuesObjects/ProductVariantGallery.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.Shared.Domain.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Products.ValuesObjects +{ + public class ProductVariantGallery : ValueObject + { + public const short Limit = 150; + private ProductVariantGallery(List values) + { + Values = values; + } + public static ProductVariantGallery CreateNew(List values) + => new ProductVariantGallery(values); + + public List Values { get; private set; } + + public static implicit operator ProductVariantGallery(List value) + => new(value); + + public static implicit operator List(ProductVariantGallery value) + => value.Values; + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Shops/Entities/Management.cs b/Vizhvizh.GoldGallery.Domain/Shops/Entities/Management.cs new file mode 100644 index 0000000..1b8a0ec --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Shops/Entities/Management.cs @@ -0,0 +1,19 @@ +using Vizhvizh.GoldGallery.Domain.Products.TypeIds; +using Vizhvizh.GoldGallery.Domain.Shops.TypeIds; +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Shops.Entities; +/// +/// مدیریت فروشگاه +/// +public class Management : Entity +{ + private Shop _shop; + + private Management() + { + } + internal static Management CreateNew() + => new Management(); + public Shop Shop => _shop; +} diff --git a/Vizhvizh.GoldGallery.Domain/Shops/Entities/ShippingMethod.cs b/Vizhvizh.GoldGallery.Domain/Shops/Entities/ShippingMethod.cs new file mode 100644 index 0000000..989f28d --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Shops/Entities/ShippingMethod.cs @@ -0,0 +1,33 @@ +using Vizhvizh.Shared.Domain.ValueObjects; +using Vizhvizh.GoldGallery.Domain.Shops.TypeIds; +using Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects; +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Shops.Entities; + +/// +/// (نوع ارسال (پست و تیپاکس +/// +public class ShippingMethod : Entity +{ + private TitleVO _title; + private DescriptionVO _description; + private ShippingMethodImage _image; + private Shop _shop; + + private ShippingMethod() + { + + } + public ShippingMethod(TitleVO title, DescriptionVO description, ShippingMethodImage image) + { + _title = title; + _description = description; + _image = image; + } + public TitleVO Title => _title; + public DescriptionVO Description => _description; + public ShippingMethodImage Image => _image; + + public Shop Shop => _shop; +} diff --git a/Vizhvizh.GoldGallery.Domain/Shops/Entities/Shop.cs b/Vizhvizh.GoldGallery.Domain/Shops/Entities/Shop.cs new file mode 100644 index 0000000..b40b17d --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Shops/Entities/Shop.cs @@ -0,0 +1,79 @@ +using Vizhvizh.Shared.Domain.ValueObjects; +using Vizhvizh.GoldGallery.Domain.Members.Entities; +using Vizhvizh.GoldGallery.Domain.Members.TypeIds; +using Vizhvizh.GoldGallery.Domain.Products.Entities; +using Vizhvizh.GoldGallery.Domain.Shops.TypeIds; +using Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects; +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Shops.Entities; + +public class Shop : Entity, IAggregateRoot +{ + private Management _management; + private List _products; + private List _shippingMethods; + private List _members; + + private ShopLocation _location; + private TitleVO _title; + private DescriptionVO? _description; + private EmailVO? _email; + private TelephoneVO _telephoneVO; + private ShopLogo _logo; + private MemberId _ownerId; + private ShopStatus _shopStatus; + private ShopBusinessLicense _businessLicense; + + private Shop() + { + + } + private Shop( + MemberId ownerId, + TitleVO title, + ShopLocation location, + TelephoneVO telephone, + ShopBusinessLicense businessLicense, + DescriptionVO? description = null, + EmailVO? email = null + ) + { + _ownerId = ownerId; + _title = title; + _location = location; + _description = description; + _businessLicense = businessLicense; + _email = email; + _telephoneVO = telephone; + _shopStatus = ShopStatus.CreateNew(ShopStatusEnum.PendingApproval); + + } + + public static Shop CreateNew(MemberId ownerId, + TitleVO title, + ShopLocation location, + TelephoneVO telephone, + ShopBusinessLicense businessLicense, + DescriptionVO? description = null, + EmailVO? email = null) + { + return new Shop(ownerId, title, location, telephone, businessLicense, description, email); + } + public MemberId OwnerId => _ownerId; + public Management Management => _management; + public ShopLocation Location => _location; + public TitleVO Title => _title; + public DescriptionVO? Description => _description; + public EmailVO? Email => _email; + public TelephoneVO Telephone => _telephoneVO; + public ShopLogo Logo => _logo; + public ShopStatus Status => _shopStatus; + public ShopBusinessLicense BusinessLicense => _businessLicense; + public IReadOnlyList Products => _products; + public IReadOnlyList ShippingMethods => _shippingMethods; + public IReadOnlyList Members => _members; + + public void SetTitle(TitleVO title) + => _title = title; +} diff --git a/Vizhvizh.GoldGallery.Domain/Shops/Repositories/IShopRepository.cs b/Vizhvizh.GoldGallery.Domain/Shops/Repositories/IShopRepository.cs new file mode 100644 index 0000000..307e8c3 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Shops/Repositories/IShopRepository.cs @@ -0,0 +1,10 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.GoldGallery.Domain.Shops.Entities; +using Vizhvizh.GoldGallery.Domain.Shops.TypeIds; + +namespace Vizhvizh.GoldGallery.Domain.Shops.Repositories; + +public interface IShopRepository : IRepositoryBase +{ + +} diff --git a/Vizhvizh.GoldGallery.Domain/Shops/TypeIds/ShippingMethodId.cs b/Vizhvizh.GoldGallery.Domain/Shops/TypeIds/ShippingMethodId.cs new file mode 100644 index 0000000..519a34a --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Shops/TypeIds/ShippingMethodId.cs @@ -0,0 +1,10 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Shops.TypeIds; + +public class ShippingMethodId : TypedIdValueBase +{ + public ShippingMethodId(int value) : base(value) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Shops/TypeIds/ShopId.cs b/Vizhvizh.GoldGallery.Domain/Shops/TypeIds/ShopId.cs new file mode 100644 index 0000000..1162fa7 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Shops/TypeIds/ShopId.cs @@ -0,0 +1,15 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Shops.TypeIds; + +public class ShopId : TypedIdValueBase +{ + public ShopId(long value) : base(value) + { + } + public static implicit operator ShopId(long value) + => new ShopId(value); + + public static implicit operator long(ShopId value) + => value.Value; +} diff --git a/Vizhvizh.GoldGallery.Domain/Shops/ValuesObjects/ShippingMethodImage.cs b/Vizhvizh.GoldGallery.Domain/Shops/ValuesObjects/ShippingMethodImage.cs new file mode 100644 index 0000000..99a0490 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Shops/ValuesObjects/ShippingMethodImage.cs @@ -0,0 +1,19 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.Shared.Domain.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects; + +public class ShippingMethodImage : ValueObject +{ + public const short Limit = 150; + private ShippingMethodImage(string value) + { + if (value.Length > Limit) + throw new CharacterLimitException(nameof(ShippingMethodImage), Limit); + Value = value; + } + public static ShippingMethodImage CreateNew(string value) + => new ShippingMethodImage(value); + + public string Value { get; init; } +} diff --git a/Vizhvizh.GoldGallery.Domain/Shops/ValuesObjects/ShopBusinessLicense.cs b/Vizhvizh.GoldGallery.Domain/Shops/ValuesObjects/ShopBusinessLicense.cs new file mode 100644 index 0000000..57bf62c --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Shops/ValuesObjects/ShopBusinessLicense.cs @@ -0,0 +1,31 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.Shared.Domain.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects; + +/// +/// پروانه کسب +/// +public class ShopBusinessLicense : ValueObject +{ + public const short ImageLimit = 150; + public const short CodeLimit = 50; + + private ShopBusinessLicense(string image, string code) + { + if (image.Length > ImageLimit) + throw new CharacterLimitException("ShopBusinessLicenseImage", ImageLimit); + if (code.Length > CodeLimit) + throw new CharacterLimitException("ShopBusinessLicenseCode", CodeLimit); + + Image = image; + Code = code; + } + + public string Image { get; private set; } + public string Code { get; private set; } + + public static ShopBusinessLicense CreateNew(string image, string code) + => new ShopBusinessLicense(image, code); + +} diff --git a/Vizhvizh.GoldGallery.Domain/Shops/ValuesObjects/ShopLocation.cs b/Vizhvizh.GoldGallery.Domain/Shops/ValuesObjects/ShopLocation.cs new file mode 100644 index 0000000..c615c64 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Shops/ValuesObjects/ShopLocation.cs @@ -0,0 +1,26 @@ +using Vizhvizh.BuildingBlocks.Domain; + + +namespace Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects; + +public class ShopLocation : ValueObject +{ + public ShopLocation(double latitude, double longitude, int provinceId, int cityId, string address, string postalCode) + { + Latitude = latitude; + Longitude = longitude; + ProvinceId = provinceId; + CityId = cityId; + Address = address; + PostalCode = postalCode; + } + public static ShopLocation CreateNew(double latitude, double longitude, int provinceId, int cityId, string address, string postalCode) + => new ShopLocation(latitude, longitude, provinceId, cityId, address, postalCode); + + public double Latitude { get; private set; } + public double Longitude { get; private set; } + public int ProvinceId { get; private set; } + public int CityId { get; private set; } + public string Address { get; private set; } + public string PostalCode { get; private set; } +} diff --git a/Vizhvizh.GoldGallery.Domain/Shops/ValuesObjects/ShopLogo.cs b/Vizhvizh.GoldGallery.Domain/Shops/ValuesObjects/ShopLogo.cs new file mode 100644 index 0000000..25a10c3 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Shops/ValuesObjects/ShopLogo.cs @@ -0,0 +1,19 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.Shared.Domain.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects; + +public class ShopLogo : ValueObject +{ + public const short Limit = 150; + private ShopLogo(string value) + { + if (string.IsNullOrWhiteSpace(value) || value.Length > Limit) + throw new CharacterLimitException(nameof(ShopLogo), Limit); + + Value = value; + } + public static ShopLogo CreateNew(string value) + => new ShopLogo(value); + public string? Value { get; init; } +} diff --git a/Vizhvizh.GoldGallery.Domain/Shops/ValuesObjects/ShopStatus.cs b/Vizhvizh.GoldGallery.Domain/Shops/ValuesObjects/ShopStatus.cs new file mode 100644 index 0000000..d7b776d --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Shops/ValuesObjects/ShopStatus.cs @@ -0,0 +1,22 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects; + +public class ShopStatus : ValueObject +{ + public ShopStatus(ShopStatusEnum value) + { + Value = value; + } + public ShopStatusEnum Value { get; private set; } + + public static ShopStatus CreateNew(ShopStatusEnum value) + => new(value); +} + +public enum ShopStatusEnum +{ + Creating = 1, + PendingApproval, + Available, +} \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Domain/Sliders/Entities/Slider.cs b/Vizhvizh.GoldGallery.Domain/Sliders/Entities/Slider.cs new file mode 100644 index 0000000..9100ddf --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Sliders/Entities/Slider.cs @@ -0,0 +1,35 @@ +using Vizhvizh.Shared.Domain.ValueObjects; +using Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects; +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.GoldGallery.Domain.Sliders.TypeIds; +using Vizhvizh.GoldGallery.Domain.Sliders.ValuesObjects; + +namespace Vizhvizh.GoldGallery.Domain.Sliders.Entities; + +public class Slider : Entity +{ + private TitleVO _title; + private SliderImage _image; + private SliderUrl _url; + private SliderKey _key; + private Slider() + { + + } + private Slider(TitleVO title, SliderImage image, SliderUrl url, SliderKey key) + { + _title = title; + _image = image; + _url = url; + _key = key; + } + public static Slider CreateNew(TitleVO title, SliderImage image, SliderUrl url, SliderKey key) + { + return new Slider(title, image, url, key); + } + + public TitleVO Title => _title; + public SliderImage Image => _image; + public SliderUrl Url => _url; + public SliderKey Key => _key; +} diff --git a/Vizhvizh.GoldGallery.Domain/Sliders/Exceptions/IsNullOrEmptySliderUrlException.cs b/Vizhvizh.GoldGallery.Domain/Sliders/Exceptions/IsNullOrEmptySliderUrlException.cs new file mode 100644 index 0000000..ff0b443 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Sliders/Exceptions/IsNullOrEmptySliderUrlException.cs @@ -0,0 +1,11 @@ +using Vizhvizh.GoldGallery.Domain.Resource.Shops; +using Vizhvizh.BuildingBlocks.Domain.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Sliders.Exceptions; + +public class IsNullOrEmptySliderUrlException : ValueObjectValidationException +{ + public IsNullOrEmptySliderUrlException() : base(ExceptionResources.IsNullOrEmptySliderUrlException) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Sliders/Repositories/ISliderRepository.cs b/Vizhvizh.GoldGallery.Domain/Sliders/Repositories/ISliderRepository.cs new file mode 100644 index 0000000..e88de3b --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Sliders/Repositories/ISliderRepository.cs @@ -0,0 +1,9 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.GoldGallery.Domain.Sliders.Entities; +using Vizhvizh.GoldGallery.Domain.Sliders.TypeIds; + +namespace Vizhvizh.GoldGallery.Domain.Sliders.Repositories; + +public interface ISliderRepository : IRepositoryBase +{ +} diff --git a/Vizhvizh.GoldGallery.Domain/Sliders/TypeIds/SliderId.cs b/Vizhvizh.GoldGallery.Domain/Sliders/TypeIds/SliderId.cs new file mode 100644 index 0000000..bb52522 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Sliders/TypeIds/SliderId.cs @@ -0,0 +1,10 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Sliders.TypeIds; + +public class SliderId : TypedIdValueBase +{ + public SliderId(long value) : base(value) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Sliders/ValuesObjects/SliderImage.cs b/Vizhvizh.GoldGallery.Domain/Sliders/ValuesObjects/SliderImage.cs new file mode 100644 index 0000000..87fa4fd --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Sliders/ValuesObjects/SliderImage.cs @@ -0,0 +1,20 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.Shared.Domain.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Sliders.ValuesObjects; + +public class SliderImage : ValueObject +{ + public const short Limit = 150; + private SliderImage(string value) + { + if (value.Length > Limit) + throw new CharacterLimitException(nameof(SliderImage), Limit); + + Value = value; + } + public static SliderImage CreateNew(string value) + => new SliderImage(value); + + public string Value { get; init; } +} diff --git a/Vizhvizh.GoldGallery.Domain/Sliders/ValuesObjects/SliderKey.cs b/Vizhvizh.GoldGallery.Domain/Sliders/ValuesObjects/SliderKey.cs new file mode 100644 index 0000000..ae5df2a --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Sliders/ValuesObjects/SliderKey.cs @@ -0,0 +1,30 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.Shared.Domain.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Sliders.ValuesObjects; + +public class SliderKey : ValueObject +{ + public const short Limit = 150; + private SliderKey() + { + + } + public SliderKey(SliderKeyType type, string? key) + { + Type = type; + Value = $"{type}/{key}"; + + if (Value.Length > Limit) + throw new CharacterLimitException(nameof(SliderKey), Limit); + } + public SliderKeyType Type { get; private set; } + public string Value { get; private set; } +} + +public enum SliderKeyType +{ + Main = 1, + Shop, + Category +} \ No newline at end of file diff --git a/Vizhvizh.GoldGallery.Domain/Sliders/ValuesObjects/SliderUrl.cs b/Vizhvizh.GoldGallery.Domain/Sliders/ValuesObjects/SliderUrl.cs new file mode 100644 index 0000000..bcf43cb --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Sliders/ValuesObjects/SliderUrl.cs @@ -0,0 +1,23 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.Shared.Domain.Exceptions; +using Vizhvizh.GoldGallery.Domain.Sliders.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Sliders.ValuesObjects; + +public class SliderUrl : ValueObject +{ + public const short Limit = 150; + private SliderUrl(string value) + { + if (string.IsNullOrWhiteSpace(value)) + throw new IsNullOrEmptySliderUrlException(); + if(value.Length > Limit) + throw new CharacterLimitException(nameof(SliderUrl), Limit); + + Value = value.Trim(); + } + public static SliderUrl CreateNew(string value) + => new SliderUrl(value); + + public string Value { get; init; } +} diff --git a/Vizhvizh.GoldGallery.Domain/Users/Entities/Resource.cs b/Vizhvizh.GoldGallery.Domain/Users/Entities/Resource.cs new file mode 100644 index 0000000..dbf6abc --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Users/Entities/Resource.cs @@ -0,0 +1,36 @@ +using Vizhvizh.Shared.Domain.ValueObjects; +using Vizhvizh.GoldGallery.Domain.Users.TypeIds; +using Vizhvizh.GoldGallery.Domain.Users.ValueObjects; +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Users.Entities; + +public class Resource : Entity +{ + private List _roles; + private TitleVO _title; + private DescriptionVO _description; + private ModuleNameVO _moduleName; + private ResourceKey _resourceKey; + + private Resource() + { + + } + public Resource(TitleVO title, DescriptionVO description, ModuleNameVO moduleNames, ResourceKey resourceKey, List roles) + { + _description = description; + _title = title; + _moduleName = moduleNames; + _resourceKey = resourceKey; + _roles = roles; + } + public static Resource CreateNew(TitleVO title, DescriptionVO description, ModuleNameVO moduleNames, ResourceKey resourceKey, List roles) + => new Resource(title, description, moduleNames, resourceKey, roles); + + public TitleVO Title => _title; + public DescriptionVO Description => _description; + public ModuleNameVO ModuleName => _moduleName; + public ResourceKey ResourceKey => _resourceKey; + public IReadOnlyList Roles => _roles; +} diff --git a/Vizhvizh.GoldGallery.Domain/Users/Entities/Role.cs b/Vizhvizh.GoldGallery.Domain/Users/Entities/Role.cs new file mode 100644 index 0000000..bca342f --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Users/Entities/Role.cs @@ -0,0 +1,26 @@ +using Vizhvizh.Shared.Domain.ValueObjects; +using Vizhvizh.GoldGallery.Domain.Users.TypeIds; +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Users.Entities; + +public class Role : Entity +{ + private TitleVO _title; + private List _roleResources; + private Role() + { + + } + private Role(TitleVO title, List roleResources) + { + _title = title; + _roleResources = roleResources; + } + public static Role CreateNew(TitleVO title, List roleResources) + => new Role(title, roleResources); + + public TitleVO Title => _title; + public IReadOnlyList RoleResources => _roleResources; + +} diff --git a/Vizhvizh.GoldGallery.Domain/Users/Entities/RoleResource.cs b/Vizhvizh.GoldGallery.Domain/Users/Entities/RoleResource.cs new file mode 100644 index 0000000..bfa2d28 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Users/Entities/RoleResource.cs @@ -0,0 +1,32 @@ +using Vizhvizh.GoldGallery.Domain.Users.TypeIds; +using Vizhvizh.GoldGallery.Domain.Users.ValueObjects; +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Users.Entities; + +public class RoleResource : Entity +{ + private AccessLevel _accessLevel; + + private User _user; + private Role _role; + + private RoleResource() + { + + } + private RoleResource(AccessLevel accessLevel, User user, Role role) + { + _accessLevel = accessLevel; + _user = user; + _role = role; + } + + public static RoleResource CreateNew(AccessLevel accessLevel, User user, Role role) + => new RoleResource(accessLevel, user, role); + + public AccessLevel AccessLevel => _accessLevel; + public User User => _user; + public Role Role => _role; + +} diff --git a/Vizhvizh.GoldGallery.Domain/Users/Entities/User.cs b/Vizhvizh.GoldGallery.Domain/Users/Entities/User.cs new file mode 100644 index 0000000..dafd007 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Users/Entities/User.cs @@ -0,0 +1,30 @@ +using Vizhvizh.GoldGallery.Domain.Members.TypeIds; +using Vizhvizh.GoldGallery.Domain.Users.TypeIds; +using Vizhvizh.GoldGallery.Domain.Users.ValueObjects; +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Users.Entities; + +public class User : Entity, IAggregateRoot +{ + //private UserNationalCode _nationalCode; + private MemberId _memberId; + private List _roles; + + private User() + { + + } + private User(MemberId memberId, List roles) + { + _memberId = memberId; + _roles = roles; + } + + public static User CreateNew(MemberId memberId, List roles) + => new User(memberId, roles); + + //public UserNationalCode NationalCode => _nationalCode; + public MemberId MemberId => _memberId; + public IReadOnlyList Roles => _roles; +} diff --git a/Vizhvizh.GoldGallery.Domain/Users/Exceptions/InvalidNationalCodeException.cs b/Vizhvizh.GoldGallery.Domain/Users/Exceptions/InvalidNationalCodeException.cs new file mode 100644 index 0000000..59a05aa --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Users/Exceptions/InvalidNationalCodeException.cs @@ -0,0 +1,11 @@ +using Vizhvizh.GoldGallery.Domain.Resource.Users; +using Vizhvizh.BuildingBlocks.Domain.Exceptions; + +namespace Vizhvizh.GoldGallery.Domain.Users.Exceptions; + +public class InvalidNationalCodeException : ValueObjectValidationException +{ + public InvalidNationalCodeException() : base(ExceptionResources.InvalidNationalCodeException) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Users/TypeIds/ResourceId.cs b/Vizhvizh.GoldGallery.Domain/Users/TypeIds/ResourceId.cs new file mode 100644 index 0000000..0001b3e --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Users/TypeIds/ResourceId.cs @@ -0,0 +1,11 @@ + +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Users.TypeIds; + +public class ResourceId : TypedIdValueBase +{ + public ResourceId(long value) : base(value) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Users/TypeIds/RoleId.cs b/Vizhvizh.GoldGallery.Domain/Users/TypeIds/RoleId.cs new file mode 100644 index 0000000..8f5cdae --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Users/TypeIds/RoleId.cs @@ -0,0 +1,10 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Users.TypeIds; + +public class RoleId : TypedIdValueBase +{ + public RoleId(int value) : base(value) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Users/TypeIds/RoleResourceId.cs b/Vizhvizh.GoldGallery.Domain/Users/TypeIds/RoleResourceId.cs new file mode 100644 index 0000000..abfac8d --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Users/TypeIds/RoleResourceId.cs @@ -0,0 +1,10 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Users.TypeIds; + +public class RoleResourceId : TypedIdValueBase +{ + public RoleResourceId(long value) : base(value) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Users/TypeIds/UserId.cs b/Vizhvizh.GoldGallery.Domain/Users/TypeIds/UserId.cs new file mode 100644 index 0000000..efc384a --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Users/TypeIds/UserId.cs @@ -0,0 +1,10 @@ +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Users.TypeIds; + +public class UserId : TypedIdValueBase +{ + public UserId(long value) : base(value) + { + } +} diff --git a/Vizhvizh.GoldGallery.Domain/Users/ValuesObjects/AccessLevel.cs b/Vizhvizh.GoldGallery.Domain/Users/ValuesObjects/AccessLevel.cs new file mode 100644 index 0000000..71da87f --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Users/ValuesObjects/AccessLevel.cs @@ -0,0 +1,25 @@ +using System.ComponentModel.DataAnnotations; +using Vizhvizh.GoldGallery.Domain.Resource.Users; +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Users.ValueObjects; + +public class AccessLevel : ValueObject +{ + private AccessLevel(AccessLevelEnum value) + { + Value = (int)value; + } + public static AccessLevel CreateNew(AccessLevelEnum value) + => new AccessLevel(value); + public int Value { get; init;} +} +public enum AccessLevelEnum +{ + [Display(Name = nameof(ValueObjectResources.AccessLevelEnum_Write), ResourceType = typeof(ValueObjectResources))] + Write = 0, + [Display(Name = nameof(ValueObjectResources.AccessLevelEnum_Read), ResourceType = typeof(ValueObjectResources))] + Read = 1, + [Display(Name = nameof(ValueObjectResources.AccessLevelEnum_ReadWrite), ResourceType = typeof(ValueObjectResources))] + ReadWrite = 2 +} diff --git a/Vizhvizh.GoldGallery.Domain/Users/ValuesObjects/ResourceKey.cs b/Vizhvizh.GoldGallery.Domain/Users/ValuesObjects/ResourceKey.cs new file mode 100644 index 0000000..da05f7e --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Users/ValuesObjects/ResourceKey.cs @@ -0,0 +1,20 @@ +using Vizhvizh.Shared.Domain.ValueObjects; +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Users.ValueObjects; + +public class ResourceKey : ValueObject +{ + private ResourceKey(ModuleNameVO module, TitleVO resourceTitle, params string[] parts) + { + Value = $"{module.Value}_{string.Join('.', parts)}_{resourceTitle.Value}"; + } + public static ResourceKey CreateNew(string value) + { + string[] valueSplit = value.Split('_'); + ModuleNamesEnum module = Enum.Parse(valueSplit[0]); + string[] paths = valueSplit[1]?.Split('.') ?? []; + return new ResourceKey(ModuleNameVO.CreateNew(module), TitleVO.CreateNew(valueSplit[2]), paths); + } + public string Value { get; init; } +} diff --git a/Vizhvizh.GoldGallery.Domain/Users/ValuesObjects/UserNationalCode.cs b/Vizhvizh.GoldGallery.Domain/Users/ValuesObjects/UserNationalCode.cs new file mode 100644 index 0000000..d0e7413 --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Users/ValuesObjects/UserNationalCode.cs @@ -0,0 +1,48 @@ +using Vizhvizh.GoldGallery.Domain.Users.Exceptions; +using Vizhvizh.BuildingBlocks.Domain; + +namespace Vizhvizh.GoldGallery.Domain.Users.ValueObjects; + +public class UserNationalCode : ValueObject +{ + public static bool IsValidNationalCode(string nationalCode) + { + if (nationalCode is null || nationalCode.Length > 10) + return false; + + // تبدیل به آرایه + var arr = nationalCode.ToArray().Select(n => int.Parse(n.ToString())); + + //بر عکس کردن اجزا + var arrReduce = arr.Reverse().ToList(); + + // بدست آوردن رقم کنترل اخر کد ملی + var numberControl = arrReduce.First(); + arrReduce.RemoveAt(0); + + // تمام 9 رقم سمت چپ کد ملی ضرب در موقعیت خودش میشه بعد همه جمع میشن بعدش تقسیم به یازده و باقی مانده رو میگیرم + //کد ملی 0700454713 + //موقیعت 07 به ترتیب 9و10 هست از اونجایی ک ما رقم کنترل رو برداشتیم پس باید ایندکس ب اضافه ی 2 شه + var remaining = decimal.Parse($"{arrReduce.Select((n, i) => n * (i + 2)).Sum() % 11}"); + + if (remaining <= 2.0m) + { + if (numberControl == remaining) + return true; + else + return false; + } + else if (11m - remaining == numberControl) + return true; + else + return false; + } + public UserNationalCode(string value) + { + if (!IsValidNationalCode(value)) + throw new InvalidNationalCodeException(); + + Value = value; + } + public string Value { get; init; } +} diff --git a/Vizhvizh.GoldGallery.Domain/Vizhvizh.GoldGallery.Domain.csproj b/Vizhvizh.GoldGallery.Domain/Vizhvizh.GoldGallery.Domain.csproj new file mode 100644 index 0000000..120d44f --- /dev/null +++ b/Vizhvizh.GoldGallery.Domain/Vizhvizh.GoldGallery.Domain.csproj @@ -0,0 +1,27 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + + + + + + + + + + + diff --git a/Vizhvizh.GoldGallery.Infrastructure/Configuration/Assemblies.cs b/Vizhvizh.GoldGallery.Infrastructure/Configuration/Assemblies.cs new file mode 100644 index 0000000..831ea39 --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/Configuration/Assemblies.cs @@ -0,0 +1,10 @@ +using System.Reflection; +using Vizhvizh.GoldGallery.Application; + +namespace Vizhvizh.GoldGallery.Infrastructure.Configuration; + +internal static class Assemblies +{ + public static Assembly Application = typeof(IGoldGalleryModule).Assembly; + public static Assembly Infrastructure = typeof(GoldGalleryStartup).Assembly; +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/Configuration/Executor.cs b/Vizhvizh.GoldGallery.Infrastructure/Configuration/Executor.cs new file mode 100644 index 0000000..28b684a --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/Configuration/Executor.cs @@ -0,0 +1,52 @@ +using Microsoft.Extensions.DependencyInjection; +using Vizhvizh.BuildingBlocks.Application.Configuration.Commnad; +using Vizhvizh.BuildingBlocks.Application.Configuration.Query; +using Vizhvizh.BuildingBlocks.Application.Contract; +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.BuildingBlocks.Domain.Contract; +using Vizhvizh.BuildingBlocks.Infrastructure; + +namespace Vizhvizh.GoldGallery.Infrastructure.Configuration; + +public class Executor : IExecutor +{ + private readonly IServiceProvider _serviceProvider; + public Executor(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } + public async Task Execute(ICommand command, CancellationToken cancellationToken) + { + var handlerType = typeof(ICommandHandler<>).MakeGenericType(command.GetType()); + var handler = _serviceProvider.GetRequiredService(handlerType); + dynamic dynamicHandler = handler; + dynamic dynamicCommand = command; + await dynamicHandler.Handle(dynamicCommand, cancellationToken); + } + + public async Task Execute(ICommand command, CancellationToken cancellationToken) + { + var handlerType = typeof(ICommandHandler<,>).MakeGenericType(command.GetType(),typeof(TResult)); + var handler = _serviceProvider.GetRequiredService(handlerType); + dynamic dynamicHandler = handler; + dynamic dynamicCommand = command; + return await dynamicHandler.Handle(dynamicCommand, cancellationToken); + } + public async Task Execute(IQuery query, CancellationToken cancellationToken) + { + var handlerType = typeof(IQueryHandler<,>).MakeGenericType(query.GetType(), typeof(TResult)); + var handler = _serviceProvider.GetRequiredService(handlerType); + dynamic dynamicHandler = handler; + dynamic dynamicQuery = query; + return await dynamicHandler.Handle(dynamicQuery, cancellationToken); + } + + public async Task Execute(IDomainEvent notification, CancellationToken cancellationToken = default) + { + var handlerType = typeof(INotificationHandler<>).MakeGenericType(notification.GetType()); + var handler = _serviceProvider.GetRequiredService(handlerType); + dynamic dynamicHandler = handler; + dynamic dynamicNotification = notification; + await dynamicHandler.Handle(dynamicNotification, cancellationToken); + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/Configuration/GoldGalleryModule.cs b/Vizhvizh.GoldGallery.Infrastructure/Configuration/GoldGalleryModule.cs new file mode 100644 index 0000000..5c4bbc1 --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/Configuration/GoldGalleryModule.cs @@ -0,0 +1,29 @@ +using Vizhvizh.GoldGallery.Application; +using Vizhvizh.BuildingBlocks.Application.Contract; +using Vizhvizh.BuildingBlocks.Domain.Contract; +using Vizhvizh.BuildingBlocks.Infrastructure; + +namespace Vizhvizh.GoldGallery.Infrastructure.Configuration; + +internal class GoldGalleryModule : IGoldGalleryModule +{ + private readonly IExecutor _executor; + public GoldGalleryModule(IExecutor executor) + { + _executor = executor; + } + public async Task ExecuteCommandAsync(ICommand command, CancellationToken cancellationToken) + { + return await _executor.Execute(command, cancellationToken); + } + + public async Task ExecuteCommandAsync(ICommand command, CancellationToken cancellationToken) + { + await _executor.Execute(command, cancellationToken); + } + + public async Task ExecuteQueryAsync(IQuery query, CancellationToken cancellationToken) + { + return await _executor.Execute(query, cancellationToken); + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/CategoryConfiguration.cs b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/CategoryConfiguration.cs new file mode 100644 index 0000000..e8f8d3e --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/CategoryConfiguration.cs @@ -0,0 +1,63 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Vizhvizh.GoldGallery.Domain.Products.Entities; +using Vizhvizh.GoldGallery.Domain.Products.TypeIds; +using Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; + +namespace Vizhvizh.GoldGallery.Infrastructure.EF.Configurations; + +internal class CategoryConfiguration : BaseEntityConfiguration +{ + public override void Configure(EntityTypeBuilder builder) + { + base.Configure(builder); + + builder.ToTable("Categories", schema: "GoldGallery"); + + builder.Property(x => x.Title) + .HasField("_title") + .IsRequired(); + + builder.Property(x => x.Description) + .IsRequired(false) + .HasField("_description"); + + builder.Property(x => x.ParentId) + .HasConversion(x => x.Value, x => new Domain.Products.TypeIds.CategoryId(x)) + .IsRequired(false) + .HasField("_parentId"); + + builder.OwnsOne(x => x.Image, sa => + { + sa.Property(x => x.Value) + .HasMaxLength(CategoryImage.Limit) + .HasColumnName("Image"); + }); + + builder.Property(x => x.Path) + .HasField("_path") + .IsRequired() + .HasConversion(x => x.Value, x => Domain.Products.ValuesObjects.CategoryPath.CreateNew(x)) + .HasColumnType("HIERARCHYID"); + + // ایندکس برای Path با نوع HIERARCHYID + builder.HasIndex(x => x.Path) + .HasDatabaseName("IX_Categories_Path") + .IsClustered(false); // معمولاً برای HierarchyId بهتر است non-clustered باشد + + // رابطه خودارجاع برای ParentId + builder.HasOne() + .WithMany() + .HasForeignKey(x => x.ParentId) + .HasConstraintName("FK_Categories_ParentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(false); + + // ایندکس برای ParentId جهت بهبود performance در کوئری‌های سلسله مراتبی + builder.HasIndex(x => x.ParentId) + .HasDatabaseName("IX_Categories_ParentId"); + + builder.Metadata.FindNavigation(nameof(Category.Products))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/Converter/MemberIdConverter.cs b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/Converter/MemberIdConverter.cs new file mode 100644 index 0000000..3d06497 --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/Converter/MemberIdConverter.cs @@ -0,0 +1,13 @@ +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using System.Linq.Expressions; +using Vizhvizh.GoldGallery.Domain.Members.TypeIds; + +namespace Vizhvizh.GoldGallery.Infrastructure.EF.Configurations.Converter; + +internal class MemberIdConverter : ValueConverter +{ + public MemberIdConverter() + : base(x=>x.Value, x=> new MemberId(x)) + { + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/Converter/ProductImageConverter.cs b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/Converter/ProductImageConverter.cs new file mode 100644 index 0000000..f4ab71f --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/Converter/ProductImageConverter.cs @@ -0,0 +1,14 @@ + +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using System.Linq.Expressions; +using Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; + +namespace Vizhvizh.GoldGallery.Infrastructure.EF.Configurations.Converter; + +internal class ProductImageConverter : ValueConverter +{ + public ProductImageConverter() + : base(x=>x.Value, x=> ProductImage.CreateNew(x)) + { + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ManagementConfiguration.cs b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ManagementConfiguration.cs new file mode 100644 index 0000000..9aa6840 --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ManagementConfiguration.cs @@ -0,0 +1,21 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Vizhvizh.GoldGallery.Domain.Shops.Entities; +using Vizhvizh.GoldGallery.Domain.Shops.TypeIds; + +namespace Vizhvizh.GoldGallery.Infrastructure.EF.Configurations; + +internal class ManagementConfiguration : BaseEntityConfiguration +{ + public override void Configure(EntityTypeBuilder builder) + { + base.Configure(builder); + + builder.ToTable("Managements", schema: "GoldGallery"); + + + builder.Metadata.FindNavigation(nameof(Management.Shop))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/MemberConfiguration.cs b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/MemberConfiguration.cs new file mode 100644 index 0000000..94ff691 --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/MemberConfiguration.cs @@ -0,0 +1,44 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Vizhvizh.GoldGallery.Domain.Members.Entities; +using Vizhvizh.GoldGallery.Domain.Members.TypeIds; +using Vizhvizh.GoldGallery.Domain.Members.ValuesObjects; + +namespace Vizhvizh.GoldGallery.Infrastructure.EF.Configurations; + +internal class MemberConfiguration : BaseEntityConfiguration +{ + public override void Configure(EntityTypeBuilder builder) + { + base.Configure(builder); + + builder.ToTable("Members", schema: "GoldGallery"); + + builder.Property(x => x.PhoneNumber) + .HasField("_phoneNumber"); + builder.OwnsOne(x => x.FullName, sa => + { + sa.Property(x => x.FirstName) + .HasMaxLength(MemberFullName.FirstNameLimit) + .HasColumnName("FirstName"); + + sa.Property(x => x.LastName) + .HasMaxLength(MemberFullName.LastNameLimit) + .HasColumnName("LastName"); + }); + builder.OwnsOne(x => x.Avatar, sa => + { + sa.Property(x => x.Value) + .HasMaxLength(MemberAvatar.Limit) + .HasColumnName("Avatar"); + }); + + builder.OwnsOne(x => x.NationalCode, sa => + { + sa.Property(x => x.Value) + .IsRequired(false) + .HasMaxLength(MemberNationalCode.Limit) + .HasColumnName("NationalCode"); + }); + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ProductConfiguration.cs b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ProductConfiguration.cs new file mode 100644 index 0000000..0053723 --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ProductConfiguration.cs @@ -0,0 +1,68 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.Drawing; +using Vizhvizh.GoldGallery.Domain.Products.Entities; +using Vizhvizh.GoldGallery.Domain.Products.TypeIds; +using Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; + +namespace Vizhvizh.GoldGallery.Infrastructure.EF.Configurations; + +internal class ProductConfiguration : BaseEntityConfiguration +{ + public override void Configure(EntityTypeBuilder builder) + { + base.Configure(builder); + + builder.ToTable("Products", schema: "GoldGallery"); + + builder.OwnsOne(x => x.ProductCondition, sa => + { + sa.Property(x => x.Value).HasColumnName("ProductCondition"); + }); + builder.Property(x => x.Title) + .HasField("_title"); + + builder.Property(x => x.Description) + .HasField("_description"); + builder.OwnsOne(x => x.Score, sa => + { + sa.Property(x => x.Score).HasColumnType("Score") + .HasColumnType("TINYINT") + .HasDefaultValue(0); + + sa.Property(x => x.TotalVoters).HasColumnName("TotalVoters") + .HasColumnType("INT") + .HasDefaultValue(0); ; + }); + + builder.OwnsOne(x => x.CraftsmanshipFee, sa => + { + sa.Property(x => x.Value) + .HasColumnType("decimal(4,2)") + .HasColumnName("CraftsmanshipFee"); + }); + + builder.OwnsOne(x => x.Image, sa => + { + sa.Property(x => x.Value) + .HasMaxLength(ProductImage.Limit) + .HasColumnName("Image"); + }); + + + builder.OwnsOne(x => x.File3D, sa => + { + sa.Property(x => x.Value) + .HasMaxLength(ProductFile3D.Limit) + .HasColumnName("File3D") + .IsRequired(false); + }); + + builder.Metadata.FindNavigation(nameof(Product.Specifications))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + builder.Metadata.FindNavigation(nameof(Product.Category))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + builder.Metadata.FindNavigation(nameof(Product.Variants))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ProductVariantConfiguration.cs b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ProductVariantConfiguration.cs new file mode 100644 index 0000000..f0311ed --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ProductVariantConfiguration.cs @@ -0,0 +1,50 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Vizhvizh.GoldGallery.Domain.Products.Entities; +using Vizhvizh.GoldGallery.Domain.Products.TypeIds; +using Vizhvizh.GoldGallery.Domain.Products.ValuesObjects; + +namespace Vizhvizh.GoldGallery.Infrastructure.EF.Configurations; + +internal class ProductVariantConfiguration : BaseEntityConfiguration +{ + public override void Configure(EntityTypeBuilder builder) + { + base.Configure(builder); + + builder.ToTable("ProductVariants", schema: "GoldGallery"); + + builder.OwnsOne(x => x.Score, sa => + { + sa.Property(x => x.Score) + .HasColumnName("Score") + .HasColumnType("TINYINT") + .HasDefaultValue(0); + + sa.Property(x => x.TotalVoters) + .HasColumnName("TotalVoters") + .HasColumnType("INT") + .HasDefaultValue(0); + }); + + builder.OwnsOne(x => x.Quantity, sa => + { + sa.Property(x => x.Value).HasColumnName("Quantity"); + }); + builder.OwnsOne(x => x.Weight, sa => + { + sa.Property(x => x.Value) + .HasColumnType("decimal(7,3)") + .HasColumnName("Weight"); + }); + + builder.OwnsOne(x => x.Gallery, sa => + { + sa.Property(x => x.Values).HasColumnName("Gallery"); + sa.ToJson(); + }); + + builder.Metadata.FindNavigation(nameof(ProductVariant.Product))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ResourceConfiguration.cs b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ResourceConfiguration.cs new file mode 100644 index 0000000..cb114f6 --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ResourceConfiguration.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Vizhvizh.Shared.Domain.ValueObjects; +using Vizhvizh.GoldGallery.Domain.Users.Entities; +using Vizhvizh.GoldGallery.Domain.Users.ValueObjects; +using Vizhvizh.GoldGallery.Domain.Users.TypeIds; + +namespace Vizhvizh.GoldGallery.Infrastructure.EF.Configurations; + +public class ResourceConfiguration : BaseEntityConfiguration +{ + public override void Configure(EntityTypeBuilder builder) + { + base.Configure(builder); + + builder.ToTable("Resources", schema: "GoldGallery"); + + builder.Property(x => x.Title) + .HasField("_title"); + builder.Property(x => x.Description) + .HasField("_description"); + builder.Property(x => x.ModuleName) + .HasField("_moduleName") + .HasColumnType("int") + .HasConversion(x=> (int)x.Value, x=> ModuleNameVO.CreateNew((ModuleNamesEnum)x)); + + builder.Property(x => x.ResourceKey) + .HasConversion(x=>x.Value, x=> ResourceKey.CreateNew(x)) + .HasField("_resourceKey"); + + + builder.Metadata.FindNavigation(nameof(Resource.Roles))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/RoleConfiguration.cs b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/RoleConfiguration.cs new file mode 100644 index 0000000..dc5833a --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/RoleConfiguration.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Vizhvizh.GoldGallery.Domain.Users.Entities; +using Vizhvizh.GoldGallery.Domain.Users.TypeIds; + +namespace Vizhvizh.GoldGallery.Infrastructure.EF.Configurations; + +public class RoleConfiguration : BaseEntityConfiguration +{ + public override void Configure(EntityTypeBuilder builder) + { + base.Configure(builder); + + builder.ToTable("Roles", schema: "GoldGallery"); + + builder.Property(x => x.Title) + .HasField("_title"); + + builder.Metadata.FindNavigation(nameof(Role.RoleResources))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/RoleResourceConfiguration.cs b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/RoleResourceConfiguration.cs new file mode 100644 index 0000000..39fe432 --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/RoleResourceConfiguration.cs @@ -0,0 +1,27 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Vizhvizh.GoldGallery.Domain.Users.Entities; +using Vizhvizh.GoldGallery.Domain.Users.TypeIds; +using Vizhvizh.GoldGallery.Domain.Users.ValueObjects; + +namespace Vizhvizh.GoldGallery.Infrastructure.EF.Configurations; + +public class RoleResourceConfiguration : BaseEntityConfiguration +{ + public override void Configure(EntityTypeBuilder builder) + { + base.Configure(builder); + + builder.ToTable("RoleResources", schema: "GoldGallery"); + + + builder.Property(x=>x.AccessLevel) + .HasConversion(x=>x.Value, x=> AccessLevel.CreateNew((AccessLevelEnum)x)); + + + builder.Metadata.FindNavigation(nameof(RoleResource.User))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + builder.Metadata.FindNavigation(nameof(RoleResource.Role))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ShippingMethodConfiguration.cs b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ShippingMethodConfiguration.cs new file mode 100644 index 0000000..940919c --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ShippingMethodConfiguration.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Vizhvizh.GoldGallery.Domain.Shops.Entities; +using Vizhvizh.GoldGallery.Domain.Shops.TypeIds; +using Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects; + +namespace Vizhvizh.GoldGallery.Infrastructure.EF.Configurations; + +internal class ShippingMethodConfiguration : BaseEntityConfiguration +{ + public override void Configure(EntityTypeBuilder builder) + { + base.Configure(builder); + builder.ToTable("ShippingMethods", schema: "GoldGallery"); + + + builder.Property(x => x.Title) + .HasField("_title"); + builder.Property(x => x.Description) + .HasField("_description"); + builder.OwnsOne(x => x.Image, sa => + { + sa.Property(x => x.Value) + .HasMaxLength(ShippingMethodImage.Limit) + .HasColumnName("Image"); + }); + builder.Metadata.FindNavigation(nameof(ShippingMethod.Shop))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ShopConfiguration.cs b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ShopConfiguration.cs new file mode 100644 index 0000000..d79ffec --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/ShopConfiguration.cs @@ -0,0 +1,69 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Vizhvizh.GoldGallery.Domain.Shops.Entities; +using Vizhvizh.GoldGallery.Domain.Shops.TypeIds; +using Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects; + +namespace Vizhvizh.GoldGallery.Infrastructure.EF.Configurations; + +public class ShopConfiguration : BaseEntityConfiguration +{ + public override void Configure(EntityTypeBuilder builder) + { + base.Configure(builder); + + builder.ToTable("Shops", schema: "GoldGallery"); + + builder.Property(x => x.OwnerId) + .HasField("_ownerId"); + builder.Property(x => x.Title) + .HasField("_title"); + builder.Property(x => x.Description) + .HasField("_description"); + builder.Property(x => x.Email) + .HasField("_email"); + builder.Property(x => x.Telephone) + .HasField("_telephoneVO"); + builder.OwnsOne(x => x.Logo, sa => + { + sa.Property(x => x.Value) + .HasMaxLength(ShopLogo.Limit) + .HasColumnName("Logo"); + }); + builder.OwnsOne(x => x.BusinessLicense, sa => + { + sa.Property(x => x.Image) + .HasMaxLength(ShopBusinessLicense.ImageLimit) + .HasColumnName("ShopBusinessLicenseImage"); + + sa.Property(x => x.Code) + .HasMaxLength(ShopBusinessLicense.CodeLimit) + .HasColumnName("ShopBusinessLicenseCode"); + + }); + builder.OwnsOne(x => x.Location, sa => + { + sa.Property(x => x.PostalCode).HasColumnName(nameof(ShopLocation.PostalCode)); + sa.Property(x => x.ProvinceId).HasColumnName(nameof(ShopLocation.ProvinceId)); + sa.Property(x => x.CityId).HasColumnName(nameof(ShopLocation.CityId)); + sa.Property(x => x.Address).HasColumnName(nameof(ShopLocation.Address)); + sa.Property(x => x.Latitude).HasColumnName(nameof(ShopLocation.Latitude)); + sa.Property(x => x.Longitude).HasColumnName(nameof(ShopLocation.Longitude)); + sa.ToJson(); + }); + + builder.HasOne(x => x.Management) + .WithOne(x => x.Shop) + .HasForeignKey(x => x.Id); + + builder.Metadata.FindNavigation(nameof(Domain.Shops.Entities.Shop.Management))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + builder.Metadata.FindNavigation(nameof(Domain.Shops.Entities.Shop.Products))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + builder.Metadata.FindNavigation(nameof(Domain.Shops.Entities.Shop.ShippingMethods))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + builder.Metadata.FindNavigation(nameof(Domain.Shops.Entities.Shop.Members))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/SliderConfiguration.cs b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/SliderConfiguration.cs new file mode 100644 index 0000000..754e6ea --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/SliderConfiguration.cs @@ -0,0 +1,44 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Vizhvizh.GoldGallery.Domain.Sliders.Entities; +using Vizhvizh.GoldGallery.Domain.Sliders.TypeIds; +using Vizhvizh.GoldGallery.Domain.Sliders.ValuesObjects; + +namespace Vizhvizh.GoldGallery.Infrastructure.EF.Configurations; + +internal class SliderConfiguration : BaseEntityConfiguration +{ + public override void Configure(EntityTypeBuilder builder) + { + base.Configure(builder); + + builder.ToTable("Sliders", schema: "GoldGallery"); + + + builder.Property(x => x.Title) + .HasField("_title"); + builder.OwnsOne(x => x.Image, sa => + { + sa.Property(x => x.Value) + .HasMaxLength(SliderImage.Limit) + .HasColumnName("Image"); + }); + builder.OwnsOne(x => x.Url, sa => + { + sa.Property(x => x.Value) + .HasMaxLength(SliderUrl.Limit) + .HasColumnName("Url"); + }); + builder.OwnsOne(x => x.Key, sa => + { + sa.Property(x => x.Value) + .HasColumnName("Key") + .HasMaxLength(SliderKey.Limit); + + sa.Property(x => x.Type) + .HasColumnName("Type") + .HasColumnType("INT"); + + }); + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/SpecificationsConfiguration.cs b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/SpecificationsConfiguration.cs new file mode 100644 index 0000000..da6596e --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/SpecificationsConfiguration.cs @@ -0,0 +1,27 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Newtonsoft.Json; +using Vizhvizh.GoldGallery.Domain.Products.Entities; +using Vizhvizh.GoldGallery.Domain.Products.TypeIds; + +namespace Vizhvizh.GoldGallery.Infrastructure.EF.Configurations; + +internal class SpecificationsConfiguration : BaseEntityConfiguration +{ + public override void Configure(EntityTypeBuilder builder) + { + base.Configure(builder); + + builder.ToTable("ProductSpecifications", schema: "GoldGallery"); + + builder.Property(x => x.Title) + .HasField("_title"); + builder.Property(x => x.ItemValues) + .HasConversion(x=> JsonConvert.SerializeObject(x), x=> JsonConvert.DeserializeObject>(x)!) + .HasField("_itemValues"); + + builder.Metadata.FindNavigation(nameof(Specifications.Product))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/UserConfiguration.cs b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/UserConfiguration.cs new file mode 100644 index 0000000..bb65b87 --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/EF/Configurations/UserConfiguration.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Vizhvizh.GoldGallery.Domain.Users.Entities; +using Vizhvizh.GoldGallery.Domain.Users.TypeIds; + +namespace Vizhvizh.GoldGallery.Infrastructure.EF.Configurations; + +public class UserConfiguration : BaseEntityConfiguration +{ + public override void Configure(EntityTypeBuilder builder) + { + base.Configure(builder); + + builder.ToTable("Users", schema: "GoldGallery"); + + //builder.OwnsOne(x => x.NationalCode, sa => + //{ + // sa.Property(x => x.Value).HasColumnName("NationalCode"); + //}); + builder.Property(x => x.MemberId); + + builder.Metadata.FindNavigation(nameof(User.Roles))? + .SetPropertyAccessMode(PropertyAccessMode.Field); + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/EF/GoldGalleryDbContext.cs b/Vizhvizh.GoldGallery.Infrastructure/EF/GoldGalleryDbContext.cs new file mode 100644 index 0000000..04cfc9f --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/EF/GoldGalleryDbContext.cs @@ -0,0 +1,79 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.IdentityModel.Abstractions; +using Vizhvizh.Shared.Domain.ValueObjects; +using Vizhvizh.Shared.Infrastructure.EF.Configurations.Converters; +using Vizhvizh.GoldGallery.Domain.Members.TypeIds; +using Vizhvizh.GoldGallery.Domain.Sliders.Entities; +using Vizhvizh.GoldGallery.Infrastructure.Configuration; +using Vizhvizh.GoldGallery.Infrastructure.EF.Configurations.Converter; + +namespace Vizhvizh.GoldGallery.Infrastructure.EF; + +internal class GoldGalleryDbContext : DbContext +{ + public GoldGalleryDbContext(DbContextOptions options) + : base(options) + { + + } + public virtual DbSet Members { get; set; } + + + public virtual DbSet Products { get; set; } + public virtual DbSet Categories { get; set; } + public virtual DbSet Specifications { get; set; } + + public virtual DbSet Shops { get; set; } + public virtual DbSet Sliders { get; set; } + public virtual DbSet ShippingMethods { get; set; } + public virtual DbSet Managements { get; set; } + + public virtual DbSet Users { get; set; } + public virtual DbSet RoleResources { get; set; } + public virtual DbSet Roles { get; set; } + public virtual DbSet Resources { get; set; } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + + modelBuilder.ApplyConfigurationsFromAssembly(Assemblies.Infrastructure, FindConfigurations); + // مرحله 1: ساخت Sequence‌ها + + modelBuilder.AddHiLoSequences(); + } + public bool FindConfigurations(Type type) + => type?.FullName?.Contains("Configurations") ?? false; + + protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) + { + configurationBuilder.Properties() + .HaveConversion(); + + configurationBuilder.Properties() + .HaveConversion(); + + configurationBuilder.Properties() + .HaveConversion() + .HaveMaxLength(TitleVO.Limit); + + configurationBuilder.Properties() + .HaveConversion() + .HaveMaxLength(DescriptionVO.Limit); + + configurationBuilder.Properties() + .HaveMaxLength(EmailVO.Limit) + .HaveConversion(); + + configurationBuilder.Properties() + .HaveConversion() + .HaveMaxLength(PhoneNumberVO.Limit); + + configurationBuilder.Properties() + .HaveConversion() + .HaveMaxLength(TelephoneVO.Limit); + + configurationBuilder.Properties() + .HaveConversion(); + } + +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/Exceptions/EntityNotFoundException.cs b/Vizhvizh.GoldGallery.Infrastructure/Exceptions/EntityNotFoundException.cs new file mode 100644 index 0000000..5fbb4df --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/Exceptions/EntityNotFoundException.cs @@ -0,0 +1,9 @@ +namespace Vizhvizh.GoldGallery.Infrastructure.Exceptions; + +public class EntityNotFoundException : Exception +{ + public EntityNotFoundException() : base("not found entity") + { + + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/GoldGalleryStartup.cs b/Vizhvizh.GoldGallery.Infrastructure/GoldGalleryStartup.cs new file mode 100644 index 0000000..6ee9290 --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/GoldGalleryStartup.cs @@ -0,0 +1,102 @@ +using Vizhvizh.GoldGallery.Application; +using Vizhvizh.GoldGallery.Infrastructure.Configuration; +using Vizhvizh.GoldGallery.Infrastructure.EF; +using Vizhvizh.BuildingBlocks.Application.Configuration.Commnad; +using Vizhvizh.BuildingBlocks.Application.Configuration.Query; +using Vizhvizh.BuildingBlocks.Application.Data; +using Vizhvizh.BuildingBlocks.Application.Events; +using Vizhvizh.BuildingBlocks.Application.Outbox; +using Vizhvizh.BuildingBlocks.Infrastructure; +using Vizhvizh.BuildingBlocks.Infrastructure.DomainEventsDispatching; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.EntityFrameworkCore; +using Vizhvizh.GoldGallery.Domain.Shops.Repositories; +using Vizhvizh.GoldGallery.Infrastructure.Repositories; +using Vizhvizh.BuildingBlocks.Infrastructure.SelectBuilders; +using Vizhvizh.BuildingBlocks.Application.SelectBuilders; +using Vizhvizh.GoldGallery.Domain.Sliders.Repositories; +using Vizhvizh.BuildingBlocks.Infrastructure.Lifetimes; +using Vizhvizh.BuildingBlocks.Application.Validations; +using FluentValidation; + + +namespace Vizhvizh.GoldGallery.Infrastructure; + +public class GoldGalleryStartup +{ + public static void Initialize(IServiceCollection services, string connectionString) + { + services.AddDbContext(op => + { + op.UseSqlServer(connectionString); + }); + services.AddScoped(sp => sp.GetRequiredService()); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + + + + services.Scan(scan => scan. + FromAssemblies(Assemblies.Application, Assemblies.Infrastructure) + + .AddClasses(classes => classes.AssignableTo(typeof(ICommandHandler<>)), publicOnly: false) + .AsImplementedInterfaces() + .WithScopedLifetime() + .AddClasses(classes => classes.AssignableTo(typeof(ICommandHandler<,>)), publicOnly: false) + .AsImplementedInterfaces() + .WithScopedLifetime() + .AddClasses(classes => classes.AssignableTo(typeof(IQueryHandler<,>)), publicOnly: false) + .AsImplementedInterfaces() + .WithScopedLifetime() + .AddClasses(classes => classes.AssignableTo(typeof(ICommandHandler<>)), publicOnly: false) + .AsImplementedInterfaces() + .WithScopedLifetime() + + .AddClasses(classes => classes.AssignableTo(typeof(ISingletonDependency)), publicOnly: false) + .AsImplementedInterfaces() + .WithSingletonLifetime() + .AddClasses(classes => classes.AssignableTo(typeof(IScopeDependency)), publicOnly: false) + .AsImplementedInterfaces() + .WithScopedLifetime() + .AddClasses(classes => classes.AssignableTo(typeof(ITransientDependency)), publicOnly: false) + .AsImplementedInterfaces() + .WithTransientLifetime() + + + .AddClasses(classes => classes.AssignableTo(typeof(IValidator<>)), publicOnly: false) + .AsImplementedInterfaces() + .WithScopedLifetime() + ); + + services.Decorate(typeof(ICommandHandler<>), typeof(ValidationCommandHandlerDecorator<>)); + services.Decorate(typeof(ICommandHandler<>), typeof(UnitOfWorkCommandHandlerDecorator<>)); + + services.Decorate(typeof(ICommandHandler<,>), typeof(ValidationCommandHandlerDecorator<,>)); + services.Decorate(typeof(ICommandHandler<,>), typeof(UnitOfWorkCommandHandlerDecorator<,>)); + services.AddScoped(sa => + { + var notifications = sa.GetServices(); + var notificationDic = new BiDictionary(); + foreach (var notification in notifications) + notificationDic.Add(notification!.ToString()!, notification!.GetType()); + + return notificationDic; + }); + services.AddScoped(sa => + { + return null; // ToDo + }); + + services.AddScoped(sp => + { + return new SqlConnectionFactory(connectionString); + }); + + services.AddScoped(); + services.AddScoped(); + } +} diff --git a/Vichvich.Shop.Infrastructure/Migrations/20260414120342_initial.Designer.cs b/Vizhvizh.GoldGallery.Infrastructure/Migrations/20260422161848_initial.Designer.cs similarity index 55% rename from Vichvich.Shop.Infrastructure/Migrations/20260414120342_initial.Designer.cs rename to Vizhvizh.GoldGallery.Infrastructure/Migrations/20260422161848_initial.Designer.cs index 4182732..d4e1723 100644 --- a/Vichvich.Shop.Infrastructure/Migrations/20260414120342_initial.Designer.cs +++ b/Vizhvizh.GoldGallery.Infrastructure/Migrations/20260422161848_initial.Designer.cs @@ -5,14 +5,14 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Vizhvizh.Shop.Infrastructure.EF; +using Vizhvizh.GoldGallery.Infrastructure.EF; #nullable disable -namespace Vizhvizh.Shop.Infrastructure.Migrations +namespace Vizhvizh.GoldGallery.Infrastructure.Migrations { - [DbContext(typeof(ShopDbContext))] - [Migration("20260414120342_initial")] + [DbContext(typeof(GoldGalleryDbContext))] + [Migration("20260422161848_initial")] partial class initial { /// @@ -25,11 +25,38 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Members.Entities.Member", b => + modelBuilder.HasSequence("Sequence_Categories", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_Managements", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_Members", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_Products", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_ProductSpecifications", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_ProductVariants", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_Resources", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_RoleResources", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_Roles", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_ShippingMethods", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_Shops", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_Sliders", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_Users", "GoldGallery"); + + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Members.Entities.Member", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Members"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -43,6 +70,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .HasMaxLength(11) .HasColumnType("nvarchar(11)"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("ShopId") .HasColumnType("bigint"); @@ -50,14 +83,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasIndex("ShopId"); - b.ToTable("Members", "Shop"); + b.ToTable("Members", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Category", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.Category", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Categories"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -77,6 +111,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .IsRequired() .HasColumnType("HIERARCHYID"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("Title") .IsRequired() .HasMaxLength(60) @@ -84,43 +124,23 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasKey("Id"); - b.ToTable("Categories", "Shop"); + b.HasIndex("ParentId") + .HasDatabaseName("IX_Categories_ParentId"); + + b.HasIndex("Path") + .HasDatabaseName("IX_Categories_Path"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("Path"), false); + + b.ToTable("Categories", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.CategoryVariantUnit", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.Product", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CategoryId") - .HasColumnType("bigint"); - - b.Property("CreateOn") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2") - .HasDefaultValueSql("GETDATE()"); - - b.Property("VariantUnitId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.HasIndex("VariantUnitId", "CategoryId") - .IsUnique(); - - b.ToTable("CategoryVariantUnit", "Shop"); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Products"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -137,6 +157,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .HasMaxLength(500) .HasColumnType("nvarchar(500)"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("ShopId") .HasColumnType("bigint"); @@ -151,14 +177,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasIndex("ShopId"); - b.ToTable("Products", "Shop"); + b.ToTable("Products", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.ProductVariant", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.ProductVariant", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_ProductVariants"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -170,23 +197,25 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Property("ProductId") .HasColumnType("bigint"); - b.Property("VariantUnitId") - .HasColumnType("bigint"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); b.HasKey("Id"); b.HasIndex("ProductId"); - b.HasIndex("VariantUnitId"); - - b.ToTable("ProductVariants", "Shop"); + b.ToTable("ProductVariants", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Specifications", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.Specifications", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_ProductSpecifications"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -202,6 +231,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Property("ProductId") .HasColumnType("bigint"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("Title") .IsRequired() .HasMaxLength(60) @@ -211,99 +246,41 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasIndex("ProductId"); - b.ToTable("ProductSpecifications", "Shop"); + b.ToTable("ProductSpecifications", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Unit", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Shops.Entities.Management", b => { b.Property("Id") - .HasColumnType("bigint"); + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None) + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Managements"); b.Property("CreateOn") .ValueGeneratedOnAdd() .HasColumnType("datetime2") .HasDefaultValueSql("GETDATE()"); - b.Property("Title") + b.Property("RowVersion") + .IsConcurrencyToken() .IsRequired() - .HasMaxLength(60) - .HasColumnType("nvarchar(60)"); + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); b.HasKey("Id"); - b.ToTable("Units", "Shop"); + b.ToTable("Managements", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Variant", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Shops.Entities.ShippingMethod", b => { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("CreateOn") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("datetime2") - .HasDefaultValueSql("GETDATE()"); + .HasColumnType("int") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_ShippingMethods"); - b.Property("Title") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("nvarchar(60)"); - - b.HasKey("Id"); - - b.ToTable("Variants", "Shop"); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.VariantUnit", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("CreateOn") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2") - .HasDefaultValueSql("GETDATE()"); - - b.Property("UnitId") - .HasColumnType("bigint"); - - b.Property("VariantId") - .HasColumnType("bigint"); - - b.Property("VariantUnitType") - .HasColumnType("INT"); - - b.HasKey("Id"); - - b.HasIndex("UnitId"); - - b.HasIndex("VariantId"); - - b.ToTable("VariantUnits", "Shop"); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Shops.Entities.Management", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("CreateOn") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2") - .HasDefaultValueSql("GETDATE()"); - - b.HasKey("Id"); - - b.ToTable("Managements", "Shop"); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Shops.Entities.ShippingMethod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("tinyint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("CreateOn") .ValueGeneratedOnAdd() @@ -315,6 +292,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .HasMaxLength(500) .HasColumnType("nvarchar(500)"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("ShopId") .HasColumnType("bigint"); @@ -327,14 +310,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasIndex("ShopId"); - b.ToTable("ShippingMethods", "Shop"); + b.ToTable("ShippingMethods", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Shops.Entities.Shop", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Shops.Entities.Shop", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Shops"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -354,6 +338,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Property("OwnerId") .HasColumnType("bigint"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("Telephone") .IsRequired() .HasMaxLength(11) @@ -366,14 +356,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasKey("Id"); - b.ToTable("Shops", "Shop"); + b.ToTable("Shops", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Sliders.Entities.Slider", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Sliders.Entities.Slider", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Sliders"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -382,6 +373,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .HasColumnType("datetime2") .HasDefaultValueSql("GETDATE()"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("Title") .IsRequired() .HasMaxLength(60) @@ -389,14 +386,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasKey("Id"); - b.ToTable("Sliders", "Shop"); + b.ToTable("Sliders", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.Resource", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.Resource", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Resources"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -417,6 +415,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("Title") .IsRequired() .HasMaxLength(60) @@ -424,14 +428,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasKey("Id"); - b.ToTable("Resources", "Shop"); + b.ToTable("Resources", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.Role", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.Role", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("int") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Roles"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -443,6 +448,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Property("ResourceId") .HasColumnType("bigint"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("Title") .IsRequired() .HasMaxLength(60) @@ -457,14 +468,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasIndex("UserId"); - b.ToTable("Roles", "Shop"); + b.ToTable("Roles", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.RoleResource", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.RoleResource", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_RoleResources"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -479,18 +491,25 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Property("RoleId") .HasColumnType("int"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.HasKey("Id"); b.HasIndex("RoleId"); - b.ToTable("RoleResources", "Shop"); + b.ToTable("RoleResources", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.User", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.User", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Users"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -502,21 +521,28 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Property("MemberId") .HasColumnType("bigint"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.HasKey("Id"); - b.ToTable("Users", "Shop"); + b.ToTable("Users", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Members.Entities.Member", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Members.Entities.Member", b => { - b.HasOne("Vizhvizh.Shop.Domain.Shops.Entities.Shop", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Shops.Entities.Shop", null) .WithMany("Members") .HasForeignKey("ShopId"); - b.OwnsOne("Vizhvizh.Shop.Domain.Members.ValuesObjects.MemberAvatar", "Avatar", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Members.ValuesObjects.MemberAvatar", "Avatar", b1 => { b1.Property("MemberId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Members"); b1.Property("Value") .IsRequired() @@ -526,16 +552,17 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("MemberId"); - b1.ToTable("Members", "Shop"); + b1.ToTable("Members", "GoldGallery"); b1.WithOwner() .HasForeignKey("MemberId"); }); - b.OwnsOne("Vizhvizh.Shop.Domain.Members.ValuesObjects.MemberFullName", "FullName", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Members.ValuesObjects.MemberFullName", "FullName", b1 => { b1.Property("MemberId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Members"); b1.Property("FirstName") .IsRequired() @@ -551,7 +578,26 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("MemberId"); - b1.ToTable("Members", "Shop"); + b1.ToTable("Members", "GoldGallery"); + + b1.WithOwner() + .HasForeignKey("MemberId"); + }); + + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Members.ValuesObjects.MemberNationalCode", "NationalCode", b1 => + { + b1.Property("MemberId") + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Members"); + + b1.Property("Value") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)") + .HasColumnName("NationalCode"); + + b1.HasKey("MemberId"); + + b1.ToTable("Members", "GoldGallery"); b1.WithOwner() .HasForeignKey("MemberId"); @@ -560,14 +606,23 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Navigation("Avatar"); b.Navigation("FullName"); + + b.Navigation("NationalCode"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Category", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.Category", b => { - b.OwnsOne("Vizhvizh.Shop.Domain.Products.ValuesObjects.CategoryImage", "Image", b1 => + b.HasOne("Vizhvizh.GoldGallery.Domain.Products.Entities.Category", null) + .WithMany() + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Restrict) + .HasConstraintName("FK_Categories_ParentId"); + + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.CategoryImage", "Image", b1 => { b1.Property("CategoryId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Categories"); b1.Property("Value") .IsRequired() @@ -577,7 +632,7 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("CategoryId"); - b1.ToTable("Categories", "Shop"); + b1.ToTable("Categories", "GoldGallery"); b1.WithOwner() .HasForeignKey("CategoryId"); @@ -587,54 +642,21 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.CategoryVariantUnit", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.Product", b => { - b.HasOne("Vizhvizh.Shop.Domain.Products.Entities.Category", null) - .WithMany("CategoryVariantUnits") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Vizhvizh.Shop.Domain.Products.Entities.VariantUnit", null) - .WithMany("CategoryVariantUnits") - .HasForeignKey("VariantUnitId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Product", b => - { - b.HasOne("Vizhvizh.Shop.Domain.Products.Entities.Category", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Products.Entities.Category", null) .WithMany("Products") .HasForeignKey("CategoryId"); - b.HasOne("Vizhvizh.Shop.Domain.Shops.Entities.Shop", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Shops.Entities.Shop", null) .WithMany("Products") .HasForeignKey("ShopId"); - b.OwnsOne("Vizhvizh.Shop.Domain.Products.ValuesObjects.ProductImage", "Image", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.ProductScore", "Score", b1 => { b1.Property("ProductId") - .HasColumnType("bigint"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)") - .HasColumnName("Image"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products", "Shop"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Vizhvizh.Shop.Domain.Products.ValuesObjects.ProductScore", "Score", b1 => - { - b1.Property("ProductId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Products"); b1.Property("Score") .ValueGeneratedOnAdd() @@ -649,16 +671,35 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("ProductId"); - b1.ToTable("Products", "Shop"); + b1.ToTable("Products", "GoldGallery"); b1.WithOwner() .HasForeignKey("ProductId"); }); - b.OwnsOne("Vizhvizh.Shop.Domain.Products.ValuesObjects.ProductCondition", "ProductCondition", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.CraftsmanshipFee", "CraftsmanshipFee", b1 => { b1.Property("ProductId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Products"); + + b1.Property("Value") + .HasColumnType("decimal(4,2)") + .HasColumnName("CraftsmanshipFee"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products", "GoldGallery"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.ProductCondition", "ProductCondition", b1 => + { + b1.Property("ProductId") + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Products"); b1.Property("Value") .HasColumnType("int") @@ -666,12 +707,56 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("ProductId"); - b1.ToTable("Products", "Shop"); + b1.ToTable("Products", "GoldGallery"); b1.WithOwner() .HasForeignKey("ProductId"); }); + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.ProductFile3D", "File3D", b1 => + { + b1.Property("ProductId") + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Products"); + + b1.Property("Value") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)") + .HasColumnName("File3D"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products", "GoldGallery"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.ProductImage", "Image", b1 => + { + b1.Property("ProductId") + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Products"); + + b1.Property("Value") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)") + .HasColumnName("Image"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products", "GoldGallery"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("CraftsmanshipFee") + .IsRequired(); + + b.Navigation("File3D"); + b.Navigation("Image") .IsRequired(); @@ -682,44 +767,17 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.ProductVariant", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.ProductVariant", b => { - b.HasOne("Vizhvizh.Shop.Domain.Products.Entities.Product", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Products.Entities.Product", null) .WithMany("Variants") .HasForeignKey("ProductId"); - b.HasOne("Vizhvizh.Shop.Domain.Products.Entities.VariantUnit", null) - .WithMany("ProductVariants") - .HasForeignKey("VariantUnitId"); - - b.OwnsMany("Vizhvizh.Shop.Domain.Products.ValuesObjects.ProductImage", "Gallery", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.ProductScore", "Score", b1 => { b1.Property("ProductVariantId") - .HasColumnType("bigint"); - - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b1.Property("Value") - .IsRequired() - .HasColumnType("nvarchar(max)") - .HasColumnName("Gallery"); - - b1.HasKey("ProductVariantId", "Id"); - - b1.ToTable("ProductVariants", "Shop"); - - b1.ToJson("Gallery"); - - b1.WithOwner() - .HasForeignKey("ProductVariantId"); - }); - - b.OwnsOne("Vizhvizh.Shop.Domain.Products.ValuesObjects.ProductScore", "Score", b1 => - { - b1.Property("ProductVariantId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_ProductVariants"); b1.Property("Score") .ValueGeneratedOnAdd() @@ -735,39 +793,35 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("ProductVariantId"); - b1.ToTable("ProductVariants", "Shop"); + b1.ToTable("ProductVariants", "GoldGallery"); b1.WithOwner() .HasForeignKey("ProductVariantId"); }); - b.OwnsOne("Vizhvizh.Shop.Domain.Products.ValuesObjects.MoneyValue", "Price", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.GoldWeight", "Weight", b1 => { b1.Property("ProductVariantId") - .HasColumnType("bigint"); - - b1.Property("Currency") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)") - .HasColumnName("Currency"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_ProductVariants"); b1.Property("Value") - .HasColumnType("decimal(18,2)") - .HasColumnName("Price"); + .HasColumnType("decimal(7,3)") + .HasColumnName("Weight"); b1.HasKey("ProductVariantId"); - b1.ToTable("ProductVariants", "Shop"); + b1.ToTable("ProductVariants", "GoldGallery"); b1.WithOwner() .HasForeignKey("ProductVariantId"); }); - b.OwnsOne("Vizhvizh.Shop.Domain.Products.ValuesObjects.ProductQuantity", "Quantity", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.ProductQuantity", "Quantity", b1 => { b1.Property("ProductVariantId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_ProductVariants"); b1.Property("Value") .HasColumnType("float") @@ -775,34 +829,34 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("ProductVariantId"); - b1.ToTable("ProductVariants", "Shop"); + b1.ToTable("ProductVariants", "GoldGallery"); b1.WithOwner() .HasForeignKey("ProductVariantId"); }); - b.OwnsOne("Vizhvizh.Shop.Domain.Products.ValuesObjects.ProductVariantValue", "Value", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.ProductVariantGallery", "Gallery", b1 => { b1.Property("ProductVariantId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_ProductVariants"); - b1.Property("Value") + b1.Property("Values") .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)") - .HasColumnName("Value"); + .HasColumnType("nvarchar(max)") + .HasColumnName("Gallery"); b1.HasKey("ProductVariantId"); - b1.ToTable("ProductVariants", "Shop"); + b1.ToTable("ProductVariants", "GoldGallery"); + + b1.ToJson("Gallery"); b1.WithOwner() .HasForeignKey("ProductVariantId"); }); - b.Navigation("Gallery"); - - b.Navigation("Price") + b.Navigation("Gallery") .IsRequired(); b.Navigation("Quantity") @@ -811,49 +865,39 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Navigation("Score") .IsRequired(); - b.Navigation("Value") + b.Navigation("Weight") .IsRequired(); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Specifications", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.Specifications", b => { - b.HasOne("Vizhvizh.Shop.Domain.Products.Entities.Product", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Products.Entities.Product", null) .WithMany("Specifications") .HasForeignKey("ProductId"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.VariantUnit", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Shops.Entities.Management", b => { - b.HasOne("Vizhvizh.Shop.Domain.Products.Entities.Unit", null) - .WithMany("VariantUnits") - .HasForeignKey("UnitId"); - - b.HasOne("Vizhvizh.Shop.Domain.Products.Entities.Variant", null) - .WithMany("VariantUnits") - .HasForeignKey("VariantId"); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Shops.Entities.Management", b => - { - b.HasOne("Vizhvizh.Shop.Domain.Shops.Entities.Shop", "Shop") + b.HasOne("Vizhvizh.GoldGallery.Domain.Shops.Entities.Shop", "Shop") .WithOne("Management") - .HasForeignKey("Vizhvizh.Shop.Domain.Shops.Entities.Management", "Id") + .HasForeignKey("Vizhvizh.GoldGallery.Domain.Shops.Entities.Management", "Id") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Shop"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Shops.Entities.ShippingMethod", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Shops.Entities.ShippingMethod", b => { - b.HasOne("Vizhvizh.Shop.Domain.Shops.Entities.Shop", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Shops.Entities.Shop", null) .WithMany("ShippingMethods") .HasForeignKey("ShopId"); - b.OwnsOne("Vizhvizh.Shop.Domain.Shops.ValuesObjects.ShippingMethodImage", "Image", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects.ShippingMethodImage", "Image", b1 => { - b1.Property("ShippingMethodId") - .HasColumnType("tinyint"); + b1.Property("ShippingMethodId") + .HasColumnType("int") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_ShippingMethods"); b1.Property("Value") .IsRequired() @@ -863,7 +907,7 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("ShippingMethodId"); - b1.ToTable("ShippingMethods", "Shop"); + b1.ToTable("ShippingMethods", "GoldGallery"); b1.WithOwner() .HasForeignKey("ShippingMethodId"); @@ -873,12 +917,39 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Shops.Entities.Shop", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Shops.Entities.Shop", b => { - b.OwnsOne("Vizhvizh.Shop.Domain.Shops.ValuesObjects.ShopLocation", "Location", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects.ShopBusinessLicense", "BusinessLicense", b1 => { b1.Property("ShopId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Shops"); + + b1.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasColumnName("ShopBusinessLicenseCode"); + + b1.Property("Image") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)") + .HasColumnName("ShopBusinessLicenseImage"); + + b1.HasKey("ShopId"); + + b1.ToTable("Shops", "GoldGallery"); + + b1.WithOwner() + .HasForeignKey("ShopId"); + }); + + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects.ShopLocation", "Location", b1 => + { + b1.Property("ShopId") + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Shops"); b1.Property("Address") .IsRequired() @@ -908,7 +979,7 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("ShopId"); - b1.ToTable("Shops", "Shop"); + b1.ToTable("Shops", "GoldGallery"); b1.ToJson("Location"); @@ -916,10 +987,11 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .HasForeignKey("ShopId"); }); - b.OwnsOne("Vizhvizh.Shop.Domain.Shops.ValuesObjects.ShopLogo", "Logo", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects.ShopLogo", "Logo", b1 => { b1.Property("ShopId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Shops"); b1.Property("Value") .HasMaxLength(150) @@ -928,12 +1000,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("ShopId"); - b1.ToTable("Shops", "Shop"); + b1.ToTable("Shops", "GoldGallery"); b1.WithOwner() .HasForeignKey("ShopId"); }); + b.Navigation("BusinessLicense") + .IsRequired(); + b.Navigation("Location") .IsRequired(); @@ -941,12 +1016,13 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Sliders.Entities.Slider", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Sliders.Entities.Slider", b => { - b.OwnsOne("Vizhvizh.Shop.Domain.Sliders.ValuesObjects.SliderImage", "Image", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Sliders.ValuesObjects.SliderImage", "Image", b1 => { b1.Property("SliderId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Sliders"); b1.Property("Value") .IsRequired() @@ -956,16 +1032,17 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("SliderId"); - b1.ToTable("Sliders", "Shop"); + b1.ToTable("Sliders", "GoldGallery"); b1.WithOwner() .HasForeignKey("SliderId"); }); - b.OwnsOne("Vizhvizh.Shop.Domain.Sliders.ValuesObjects.SliderKey", "Key", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Sliders.ValuesObjects.SliderKey", "Key", b1 => { b1.Property("SliderId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Sliders"); b1.Property("Type") .HasColumnType("INT") @@ -979,16 +1056,17 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("SliderId"); - b1.ToTable("Sliders", "Shop"); + b1.ToTable("Sliders", "GoldGallery"); b1.WithOwner() .HasForeignKey("SliderId"); }); - b.OwnsOne("Vizhvizh.Shop.Domain.Sliders.ValuesObjects.SliderUrl", "Url", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Sliders.ValuesObjects.SliderUrl", "Url", b1 => { b1.Property("SliderId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Sliders"); b1.Property("Value") .IsRequired() @@ -998,7 +1076,7 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("SliderId"); - b1.ToTable("Sliders", "Shop"); + b1.ToTable("Sliders", "GoldGallery"); b1.WithOwner() .HasForeignKey("SliderId"); @@ -1014,56 +1092,37 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.Role", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.Role", b => { - b.HasOne("Vizhvizh.Shop.Domain.Users.Entities.Resource", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Users.Entities.Resource", null) .WithMany("Roles") .HasForeignKey("ResourceId"); - b.HasOne("Vizhvizh.Shop.Domain.Users.Entities.User", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Users.Entities.User", null) .WithMany("Roles") .HasForeignKey("UserId"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.RoleResource", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.RoleResource", b => { - b.HasOne("Vizhvizh.Shop.Domain.Users.Entities.Role", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Users.Entities.Role", null) .WithMany("RoleResources") .HasForeignKey("RoleId"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Category", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.Category", b => { - b.Navigation("CategoryVariantUnits"); - b.Navigation("Products"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Product", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.Product", b => { b.Navigation("Specifications"); b.Navigation("Variants"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Unit", b => - { - b.Navigation("VariantUnits"); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Variant", b => - { - b.Navigation("VariantUnits"); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.VariantUnit", b => - { - b.Navigation("CategoryVariantUnits"); - - b.Navigation("ProductVariants"); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Shops.Entities.Shop", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Shops.Entities.Shop", b => { b.Navigation("Management") .IsRequired(); @@ -1075,17 +1134,17 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Navigation("ShippingMethods"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.Resource", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.Resource", b => { b.Navigation("Roles"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.Role", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.Role", b => { b.Navigation("RoleResources"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.User", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.User", b => { b.Navigation("Roles"); }); diff --git a/Vichvich.Shop.Infrastructure/Migrations/20260414120342_initial.cs b/Vizhvizh.GoldGallery.Infrastructure/Migrations/20260422161848_initial.cs similarity index 68% rename from Vichvich.Shop.Infrastructure/Migrations/20260414120342_initial.cs rename to Vizhvizh.GoldGallery.Infrastructure/Migrations/20260422161848_initial.cs index b19f65f..fe49d99 100644 --- a/Vichvich.Shop.Infrastructure/Migrations/20260414120342_initial.cs +++ b/Vizhvizh.GoldGallery.Infrastructure/Migrations/20260422161848_initial.cs @@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace Vizhvizh.Shop.Infrastructure.Migrations +namespace Vizhvizh.GoldGallery.Infrastructure.Migrations { /// public partial class initial : Migration @@ -12,11 +12,63 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.EnsureSchema( - name: "Shop"); + name: "GoldGallery"); + + migrationBuilder.CreateSequence( + name: "Sequence_Categories", + schema: "GoldGallery"); + + migrationBuilder.CreateSequence( + name: "Sequence_Managements", + schema: "GoldGallery"); + + migrationBuilder.CreateSequence( + name: "Sequence_Members", + schema: "GoldGallery"); + + migrationBuilder.CreateSequence( + name: "Sequence_Products", + schema: "GoldGallery"); + + migrationBuilder.CreateSequence( + name: "Sequence_ProductSpecifications", + schema: "GoldGallery"); + + migrationBuilder.CreateSequence( + name: "Sequence_ProductVariants", + schema: "GoldGallery"); + + migrationBuilder.CreateSequence( + name: "Sequence_Resources", + schema: "GoldGallery"); + + migrationBuilder.CreateSequence( + name: "Sequence_RoleResources", + schema: "GoldGallery"); + + migrationBuilder.CreateSequence( + name: "Sequence_Roles", + schema: "GoldGallery"); + + migrationBuilder.CreateSequence( + name: "Sequence_ShippingMethods", + schema: "GoldGallery"); + + migrationBuilder.CreateSequence( + name: "Sequence_Shops", + schema: "GoldGallery"); + + migrationBuilder.CreateSequence( + name: "Sequence_Sliders", + schema: "GoldGallery"); + + migrationBuilder.CreateSequence( + name: "Sequence_Users", + schema: "GoldGallery"); migrationBuilder.CreateTable( name: "Categories", - schema: "Shop", + schema: "GoldGallery", columns: table => new { Id = table.Column(type: "bigint", nullable: false) @@ -26,16 +78,24 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations Image = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false), ParentId = table.Column(type: "bigint", nullable: true), Path = table.Column(type: "HIERARCHYID", nullable: false), + RowVersion = table.Column(type: "rowversion", rowVersion: true, nullable: false), CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()") }, constraints: table => { table.PrimaryKey("PK_Categories", x => x.Id); + table.ForeignKey( + name: "FK_Categories_ParentId", + column: x => x.ParentId, + principalSchema: "GoldGallery", + principalTable: "Categories", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Resources", - schema: "Shop", + schema: "GoldGallery", columns: table => new { Id = table.Column(type: "bigint", nullable: false) @@ -44,6 +104,7 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations Description = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false), ModuleName = table.Column(type: "int", nullable: false), ResourceKey = table.Column(type: "nvarchar(max)", nullable: false), + RowVersion = table.Column(type: "rowversion", rowVersion: true, nullable: false), CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()") }, constraints: table => @@ -53,7 +114,7 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations migrationBuilder.CreateTable( name: "Shops", - schema: "Shop", + schema: "GoldGallery", columns: table => new { Id = table.Column(type: "bigint", nullable: false) @@ -64,6 +125,9 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations Email = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), Telephone = table.Column(type: "nvarchar(11)", maxLength: 11, nullable: false), Logo = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: true), + ShopBusinessLicenseImage = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false), + ShopBusinessLicenseCode = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + RowVersion = table.Column(type: "rowversion", rowVersion: true, nullable: false), CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"), Location = table.Column(type: "nvarchar(max)", nullable: false) }, @@ -74,7 +138,7 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations migrationBuilder.CreateTable( name: "Sliders", - schema: "Shop", + schema: "GoldGallery", columns: table => new { Id = table.Column(type: "bigint", nullable: false) @@ -84,6 +148,7 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations Url = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false), Type = table.Column(type: "INT", nullable: false), Key = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false), + RowVersion = table.Column(type: "rowversion", rowVersion: true, nullable: false), CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()") }, constraints: table => @@ -91,28 +156,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations table.PrimaryKey("PK_Sliders", x => x.Id); }); - migrationBuilder.CreateTable( - name: "Units", - schema: "Shop", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false), - Title = table.Column(type: "nvarchar(60)", maxLength: 60, nullable: false), - CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()") - }, - constraints: table => - { - table.PrimaryKey("PK_Units", x => x.Id); - }); - migrationBuilder.CreateTable( name: "Users", - schema: "Shop", + schema: "GoldGallery", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), MemberId = table.Column(type: "bigint", nullable: false), + RowVersion = table.Column(type: "rowversion", rowVersion: true, nullable: false), CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()") }, constraints: table => @@ -120,26 +172,13 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations table.PrimaryKey("PK_Users", x => x.Id); }); - migrationBuilder.CreateTable( - name: "Variants", - schema: "Shop", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false), - Title = table.Column(type: "nvarchar(60)", maxLength: 60, nullable: false), - CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()") - }, - constraints: table => - { - table.PrimaryKey("PK_Variants", x => x.Id); - }); - migrationBuilder.CreateTable( name: "Managements", - schema: "Shop", + schema: "GoldGallery", columns: table => new { Id = table.Column(type: "bigint", nullable: false), + RowVersion = table.Column(type: "rowversion", rowVersion: true, nullable: false), CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()") }, constraints: table => @@ -148,7 +187,7 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations table.ForeignKey( name: "FK_Managements_Shops_Id", column: x => x.Id, - principalSchema: "Shop", + principalSchema: "GoldGallery", principalTable: "Shops", principalColumn: "Id", onDelete: ReferentialAction.Cascade); @@ -156,7 +195,7 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations migrationBuilder.CreateTable( name: "Members", - schema: "Shop", + schema: "GoldGallery", columns: table => new { Id = table.Column(type: "bigint", nullable: false) @@ -165,7 +204,9 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations LastName = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), PhoneNumber = table.Column(type: "nvarchar(11)", maxLength: 11, nullable: false), Avatar = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: true), + NationalCode = table.Column(type: "nvarchar(10)", maxLength: 10, nullable: true), ShopId = table.Column(type: "bigint", nullable: true), + RowVersion = table.Column(type: "rowversion", rowVersion: true, nullable: false), CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()") }, constraints: table => @@ -174,14 +215,14 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations table.ForeignKey( name: "FK_Members_Shops_ShopId", column: x => x.ShopId, - principalSchema: "Shop", + principalSchema: "GoldGallery", principalTable: "Shops", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Products", - schema: "Shop", + schema: "GoldGallery", columns: table => new { Id = table.Column(type: "bigint", nullable: false) @@ -192,8 +233,11 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations Score_Score = table.Column(type: "TINYINT", nullable: false, defaultValue: (byte)0), TotalVoters = table.Column(type: "INT", nullable: false, defaultValue: 0), Image = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false), + File3D = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: true), + CraftsmanshipFee = table.Column(type: "decimal(4,2)", nullable: false), CategoryId = table.Column(type: "bigint", nullable: true), ShopId = table.Column(type: "bigint", nullable: true), + RowVersion = table.Column(type: "rowversion", rowVersion: true, nullable: false), CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()") }, constraints: table => @@ -202,28 +246,29 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations table.ForeignKey( name: "FK_Products_Categories_CategoryId", column: x => x.CategoryId, - principalSchema: "Shop", + principalSchema: "GoldGallery", principalTable: "Categories", principalColumn: "Id"); table.ForeignKey( name: "FK_Products_Shops_ShopId", column: x => x.ShopId, - principalSchema: "Shop", + principalSchema: "GoldGallery", principalTable: "Shops", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "ShippingMethods", - schema: "Shop", + schema: "GoldGallery", columns: table => new { - Id = table.Column(type: "tinyint", nullable: false) + Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Title = table.Column(type: "nvarchar(60)", maxLength: 60, nullable: false), Description = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false), Image = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false), ShopId = table.Column(type: "bigint", nullable: true), + RowVersion = table.Column(type: "rowversion", rowVersion: true, nullable: false), CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()") }, constraints: table => @@ -232,14 +277,14 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations table.ForeignKey( name: "FK_ShippingMethods_Shops_ShopId", column: x => x.ShopId, - principalSchema: "Shop", + principalSchema: "GoldGallery", principalTable: "Shops", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Roles", - schema: "Shop", + schema: "GoldGallery", columns: table => new { Id = table.Column(type: "int", nullable: false) @@ -247,6 +292,7 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations Title = table.Column(type: "nvarchar(60)", maxLength: 60, nullable: false), ResourceId = table.Column(type: "bigint", nullable: true), UserId = table.Column(type: "bigint", nullable: true), + RowVersion = table.Column(type: "rowversion", rowVersion: true, nullable: false), CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()") }, constraints: table => @@ -255,48 +301,20 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations table.ForeignKey( name: "FK_Roles_Resources_ResourceId", column: x => x.ResourceId, - principalSchema: "Shop", + principalSchema: "GoldGallery", principalTable: "Resources", principalColumn: "Id"); table.ForeignKey( name: "FK_Roles_Users_UserId", column: x => x.UserId, - principalSchema: "Shop", + principalSchema: "GoldGallery", principalTable: "Users", principalColumn: "Id"); }); - migrationBuilder.CreateTable( - name: "VariantUnits", - schema: "Shop", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false), - VariantUnitType = table.Column(type: "INT", nullable: false), - UnitId = table.Column(type: "bigint", nullable: true), - VariantId = table.Column(type: "bigint", nullable: true), - CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()") - }, - constraints: table => - { - table.PrimaryKey("PK_VariantUnits", x => x.Id); - table.ForeignKey( - name: "FK_VariantUnits_Units_UnitId", - column: x => x.UnitId, - principalSchema: "Shop", - principalTable: "Units", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_VariantUnits_Variants_VariantId", - column: x => x.VariantId, - principalSchema: "Shop", - principalTable: "Variants", - principalColumn: "Id"); - }); - migrationBuilder.CreateTable( name: "ProductSpecifications", - schema: "Shop", + schema: "GoldGallery", columns: table => new { Id = table.Column(type: "bigint", nullable: false) @@ -304,6 +322,7 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations Title = table.Column(type: "nvarchar(60)", maxLength: 60, nullable: false), ItemValues = table.Column(type: "nvarchar(max)", nullable: false), ProductId = table.Column(type: "bigint", nullable: true), + RowVersion = table.Column(type: "rowversion", rowVersion: true, nullable: false), CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()") }, constraints: table => @@ -312,20 +331,48 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations table.ForeignKey( name: "FK_ProductSpecifications_Products_ProductId", column: x => x.ProductId, - principalSchema: "Shop", + principalSchema: "GoldGallery", + principalTable: "Products", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "ProductVariants", + schema: "GoldGallery", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Score = table.Column(type: "TINYINT", nullable: false, defaultValue: (byte)0), + TotalVoters = table.Column(type: "INT", nullable: false, defaultValue: 0), + Quantity = table.Column(type: "float", nullable: false), + Weight = table.Column(type: "decimal(7,3)", nullable: false), + ProductId = table.Column(type: "bigint", nullable: true), + RowVersion = table.Column(type: "rowversion", rowVersion: true, nullable: false), + CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"), + Gallery = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductVariants", x => x.Id); + table.ForeignKey( + name: "FK_ProductVariants_Products_ProductId", + column: x => x.ProductId, + principalSchema: "GoldGallery", principalTable: "Products", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "RoleResources", - schema: "Shop", + schema: "GoldGallery", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), AccessLevel = table.Column(type: "int", nullable: false), RoleId = table.Column(type: "int", nullable: true), + RowVersion = table.Column(type: "rowversion", rowVersion: true, nullable: false), CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()") }, constraints: table => @@ -334,232 +381,185 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations table.ForeignKey( name: "FK_RoleResources_Roles_RoleId", column: x => x.RoleId, - principalSchema: "Shop", + principalSchema: "GoldGallery", principalTable: "Roles", principalColumn: "Id"); }); - migrationBuilder.CreateTable( - name: "CategoryVariantUnit", - schema: "Shop", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - CategoryId = table.Column(type: "bigint", nullable: false), - VariantUnitId = table.Column(type: "bigint", nullable: false), - CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()") - }, - constraints: table => - { - table.PrimaryKey("PK_CategoryVariantUnit", x => x.Id); - table.ForeignKey( - name: "FK_CategoryVariantUnit_Categories_CategoryId", - column: x => x.CategoryId, - principalSchema: "Shop", - principalTable: "Categories", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_CategoryVariantUnit_VariantUnits_VariantUnitId", - column: x => x.VariantUnitId, - principalSchema: "Shop", - principalTable: "VariantUnits", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ProductVariants", - schema: "Shop", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Price = table.Column(type: "decimal(18,2)", nullable: false), - Currency = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false), - Score = table.Column(type: "TINYINT", nullable: false, defaultValue: (byte)0), - TotalVoters = table.Column(type: "INT", nullable: false, defaultValue: 0), - Quantity = table.Column(type: "float", nullable: false), - Value = table.Column(type: "nvarchar(120)", maxLength: 120, nullable: false), - ProductId = table.Column(type: "bigint", nullable: true), - VariantUnitId = table.Column(type: "bigint", nullable: true), - CreateOn = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"), - Gallery = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ProductVariants", x => x.Id); - table.ForeignKey( - name: "FK_ProductVariants_Products_ProductId", - column: x => x.ProductId, - principalSchema: "Shop", - principalTable: "Products", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_ProductVariants_VariantUnits_VariantUnitId", - column: x => x.VariantUnitId, - principalSchema: "Shop", - principalTable: "VariantUnits", - principalColumn: "Id"); - }); + migrationBuilder.CreateIndex( + name: "IX_Categories_ParentId", + schema: "GoldGallery", + table: "Categories", + column: "ParentId"); migrationBuilder.CreateIndex( - name: "IX_CategoryVariantUnit_CategoryId", - schema: "Shop", - table: "CategoryVariantUnit", - column: "CategoryId"); - - migrationBuilder.CreateIndex( - name: "IX_CategoryVariantUnit_VariantUnitId_CategoryId", - schema: "Shop", - table: "CategoryVariantUnit", - columns: new[] { "VariantUnitId", "CategoryId" }, - unique: true); + name: "IX_Categories_Path", + schema: "GoldGallery", + table: "Categories", + column: "Path") + .Annotation("SqlServer:Clustered", false); migrationBuilder.CreateIndex( name: "IX_Members_ShopId", - schema: "Shop", + schema: "GoldGallery", table: "Members", column: "ShopId"); migrationBuilder.CreateIndex( name: "IX_Products_CategoryId", - schema: "Shop", + schema: "GoldGallery", table: "Products", column: "CategoryId"); migrationBuilder.CreateIndex( name: "IX_Products_ShopId", - schema: "Shop", + schema: "GoldGallery", table: "Products", column: "ShopId"); migrationBuilder.CreateIndex( name: "IX_ProductSpecifications_ProductId", - schema: "Shop", + schema: "GoldGallery", table: "ProductSpecifications", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_ProductVariants_ProductId", - schema: "Shop", + schema: "GoldGallery", table: "ProductVariants", column: "ProductId"); - migrationBuilder.CreateIndex( - name: "IX_ProductVariants_VariantUnitId", - schema: "Shop", - table: "ProductVariants", - column: "VariantUnitId"); - migrationBuilder.CreateIndex( name: "IX_RoleResources_RoleId", - schema: "Shop", + schema: "GoldGallery", table: "RoleResources", column: "RoleId"); migrationBuilder.CreateIndex( name: "IX_Roles_ResourceId", - schema: "Shop", + schema: "GoldGallery", table: "Roles", column: "ResourceId"); migrationBuilder.CreateIndex( name: "IX_Roles_UserId", - schema: "Shop", + schema: "GoldGallery", table: "Roles", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_ShippingMethods_ShopId", - schema: "Shop", + schema: "GoldGallery", table: "ShippingMethods", column: "ShopId"); - - migrationBuilder.CreateIndex( - name: "IX_VariantUnits_UnitId", - schema: "Shop", - table: "VariantUnits", - column: "UnitId"); - - migrationBuilder.CreateIndex( - name: "IX_VariantUnits_VariantId", - schema: "Shop", - table: "VariantUnits", - column: "VariantId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { - migrationBuilder.DropTable( - name: "CategoryVariantUnit", - schema: "Shop"); - migrationBuilder.DropTable( name: "Managements", - schema: "Shop"); + schema: "GoldGallery"); migrationBuilder.DropTable( name: "Members", - schema: "Shop"); + schema: "GoldGallery"); migrationBuilder.DropTable( name: "ProductSpecifications", - schema: "Shop"); + schema: "GoldGallery"); migrationBuilder.DropTable( name: "ProductVariants", - schema: "Shop"); + schema: "GoldGallery"); migrationBuilder.DropTable( name: "RoleResources", - schema: "Shop"); + schema: "GoldGallery"); migrationBuilder.DropTable( name: "ShippingMethods", - schema: "Shop"); + schema: "GoldGallery"); migrationBuilder.DropTable( name: "Sliders", - schema: "Shop"); + schema: "GoldGallery"); migrationBuilder.DropTable( name: "Products", - schema: "Shop"); - - migrationBuilder.DropTable( - name: "VariantUnits", - schema: "Shop"); + schema: "GoldGallery"); migrationBuilder.DropTable( name: "Roles", - schema: "Shop"); + schema: "GoldGallery"); migrationBuilder.DropTable( name: "Categories", - schema: "Shop"); + schema: "GoldGallery"); migrationBuilder.DropTable( name: "Shops", - schema: "Shop"); - - migrationBuilder.DropTable( - name: "Units", - schema: "Shop"); - - migrationBuilder.DropTable( - name: "Variants", - schema: "Shop"); + schema: "GoldGallery"); migrationBuilder.DropTable( name: "Resources", - schema: "Shop"); + schema: "GoldGallery"); migrationBuilder.DropTable( name: "Users", - schema: "Shop"); + schema: "GoldGallery"); + + migrationBuilder.DropSequence( + name: "Sequence_Categories", + schema: "GoldGallery"); + + migrationBuilder.DropSequence( + name: "Sequence_Managements", + schema: "GoldGallery"); + + migrationBuilder.DropSequence( + name: "Sequence_Members", + schema: "GoldGallery"); + + migrationBuilder.DropSequence( + name: "Sequence_Products", + schema: "GoldGallery"); + + migrationBuilder.DropSequence( + name: "Sequence_ProductSpecifications", + schema: "GoldGallery"); + + migrationBuilder.DropSequence( + name: "Sequence_ProductVariants", + schema: "GoldGallery"); + + migrationBuilder.DropSequence( + name: "Sequence_Resources", + schema: "GoldGallery"); + + migrationBuilder.DropSequence( + name: "Sequence_RoleResources", + schema: "GoldGallery"); + + migrationBuilder.DropSequence( + name: "Sequence_Roles", + schema: "GoldGallery"); + + migrationBuilder.DropSequence( + name: "Sequence_ShippingMethods", + schema: "GoldGallery"); + + migrationBuilder.DropSequence( + name: "Sequence_Shops", + schema: "GoldGallery"); + + migrationBuilder.DropSequence( + name: "Sequence_Sliders", + schema: "GoldGallery"); + + migrationBuilder.DropSequence( + name: "Sequence_Users", + schema: "GoldGallery"); } } } diff --git a/Vichvich.Shop.Infrastructure/Migrations/ShopDbContextModelSnapshot.cs b/Vizhvizh.GoldGallery.Infrastructure/Migrations/GoldGalleryDbContextModelSnapshot.cs similarity index 55% rename from Vichvich.Shop.Infrastructure/Migrations/ShopDbContextModelSnapshot.cs rename to Vizhvizh.GoldGallery.Infrastructure/Migrations/GoldGalleryDbContextModelSnapshot.cs index 7f205aa..f22e662 100644 --- a/Vichvich.Shop.Infrastructure/Migrations/ShopDbContextModelSnapshot.cs +++ b/Vizhvizh.GoldGallery.Infrastructure/Migrations/GoldGalleryDbContextModelSnapshot.cs @@ -4,14 +4,14 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Vizhvizh.Shop.Infrastructure.EF; +using Vizhvizh.GoldGallery.Infrastructure.EF; #nullable disable -namespace Vizhvizh.Shop.Infrastructure.Migrations +namespace Vizhvizh.GoldGallery.Infrastructure.Migrations { - [DbContext(typeof(ShopDbContext))] - partial class ShopDbContextModelSnapshot : ModelSnapshot + [DbContext(typeof(GoldGalleryDbContext))] + partial class GoldGalleryDbContextModelSnapshot : ModelSnapshot { protected override void BuildModel(ModelBuilder modelBuilder) { @@ -22,11 +22,38 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Members.Entities.Member", b => + modelBuilder.HasSequence("Sequence_Categories", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_Managements", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_Members", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_Products", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_ProductSpecifications", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_ProductVariants", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_Resources", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_RoleResources", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_Roles", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_ShippingMethods", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_Shops", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_Sliders", "GoldGallery"); + + modelBuilder.HasSequence("Sequence_Users", "GoldGallery"); + + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Members.Entities.Member", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Members"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -40,6 +67,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .HasMaxLength(11) .HasColumnType("nvarchar(11)"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("ShopId") .HasColumnType("bigint"); @@ -47,14 +80,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasIndex("ShopId"); - b.ToTable("Members", "Shop"); + b.ToTable("Members", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Category", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.Category", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Categories"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -74,6 +108,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .IsRequired() .HasColumnType("HIERARCHYID"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("Title") .IsRequired() .HasMaxLength(60) @@ -81,43 +121,23 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasKey("Id"); - b.ToTable("Categories", "Shop"); + b.HasIndex("ParentId") + .HasDatabaseName("IX_Categories_ParentId"); + + b.HasIndex("Path") + .HasDatabaseName("IX_Categories_Path"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("Path"), false); + + b.ToTable("Categories", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.CategoryVariantUnit", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.Product", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CategoryId") - .HasColumnType("bigint"); - - b.Property("CreateOn") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2") - .HasDefaultValueSql("GETDATE()"); - - b.Property("VariantUnitId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.HasIndex("VariantUnitId", "CategoryId") - .IsUnique(); - - b.ToTable("CategoryVariantUnit", "Shop"); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Products"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -134,6 +154,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .HasMaxLength(500) .HasColumnType("nvarchar(500)"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("ShopId") .HasColumnType("bigint"); @@ -148,14 +174,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasIndex("ShopId"); - b.ToTable("Products", "Shop"); + b.ToTable("Products", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.ProductVariant", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.ProductVariant", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_ProductVariants"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -167,23 +194,25 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Property("ProductId") .HasColumnType("bigint"); - b.Property("VariantUnitId") - .HasColumnType("bigint"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); b.HasKey("Id"); b.HasIndex("ProductId"); - b.HasIndex("VariantUnitId"); - - b.ToTable("ProductVariants", "Shop"); + b.ToTable("ProductVariants", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Specifications", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.Specifications", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_ProductSpecifications"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -199,6 +228,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Property("ProductId") .HasColumnType("bigint"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("Title") .IsRequired() .HasMaxLength(60) @@ -208,99 +243,41 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasIndex("ProductId"); - b.ToTable("ProductSpecifications", "Shop"); + b.ToTable("ProductSpecifications", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Unit", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Shops.Entities.Management", b => { b.Property("Id") - .HasColumnType("bigint"); + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None) + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Managements"); b.Property("CreateOn") .ValueGeneratedOnAdd() .HasColumnType("datetime2") .HasDefaultValueSql("GETDATE()"); - b.Property("Title") + b.Property("RowVersion") + .IsConcurrencyToken() .IsRequired() - .HasMaxLength(60) - .HasColumnType("nvarchar(60)"); + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); b.HasKey("Id"); - b.ToTable("Units", "Shop"); + b.ToTable("Managements", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Variant", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Shops.Entities.ShippingMethod", b => { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("CreateOn") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("datetime2") - .HasDefaultValueSql("GETDATE()"); + .HasColumnType("int") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_ShippingMethods"); - b.Property("Title") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("nvarchar(60)"); - - b.HasKey("Id"); - - b.ToTable("Variants", "Shop"); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.VariantUnit", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("CreateOn") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2") - .HasDefaultValueSql("GETDATE()"); - - b.Property("UnitId") - .HasColumnType("bigint"); - - b.Property("VariantId") - .HasColumnType("bigint"); - - b.Property("VariantUnitType") - .HasColumnType("INT"); - - b.HasKey("Id"); - - b.HasIndex("UnitId"); - - b.HasIndex("VariantId"); - - b.ToTable("VariantUnits", "Shop"); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Shops.Entities.Management", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("CreateOn") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2") - .HasDefaultValueSql("GETDATE()"); - - b.HasKey("Id"); - - b.ToTable("Managements", "Shop"); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Shops.Entities.ShippingMethod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("tinyint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("CreateOn") .ValueGeneratedOnAdd() @@ -312,6 +289,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .HasMaxLength(500) .HasColumnType("nvarchar(500)"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("ShopId") .HasColumnType("bigint"); @@ -324,14 +307,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasIndex("ShopId"); - b.ToTable("ShippingMethods", "Shop"); + b.ToTable("ShippingMethods", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Shops.Entities.Shop", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Shops.Entities.Shop", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Shops"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -351,6 +335,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Property("OwnerId") .HasColumnType("bigint"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("Telephone") .IsRequired() .HasMaxLength(11) @@ -363,14 +353,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasKey("Id"); - b.ToTable("Shops", "Shop"); + b.ToTable("Shops", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Sliders.Entities.Slider", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Sliders.Entities.Slider", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Sliders"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -379,6 +370,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .HasColumnType("datetime2") .HasDefaultValueSql("GETDATE()"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("Title") .IsRequired() .HasMaxLength(60) @@ -386,14 +383,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasKey("Id"); - b.ToTable("Sliders", "Shop"); + b.ToTable("Sliders", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.Resource", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.Resource", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Resources"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -414,6 +412,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("Title") .IsRequired() .HasMaxLength(60) @@ -421,14 +425,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasKey("Id"); - b.ToTable("Resources", "Shop"); + b.ToTable("Resources", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.Role", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.Role", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("int") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Roles"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -440,6 +445,12 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Property("ResourceId") .HasColumnType("bigint"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.Property("Title") .IsRequired() .HasMaxLength(60) @@ -454,14 +465,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.HasIndex("UserId"); - b.ToTable("Roles", "Shop"); + b.ToTable("Roles", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.RoleResource", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.RoleResource", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_RoleResources"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -476,18 +488,25 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Property("RoleId") .HasColumnType("int"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.HasKey("Id"); b.HasIndex("RoleId"); - b.ToTable("RoleResources", "Shop"); + b.ToTable("RoleResources", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.User", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.User", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Users"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); @@ -499,21 +518,28 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Property("MemberId") .HasColumnType("bigint"); + b.Property("RowVersion") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + b.HasKey("Id"); - b.ToTable("Users", "Shop"); + b.ToTable("Users", "GoldGallery"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Members.Entities.Member", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Members.Entities.Member", b => { - b.HasOne("Vizhvizh.Shop.Domain.Shops.Entities.Shop", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Shops.Entities.Shop", null) .WithMany("Members") .HasForeignKey("ShopId"); - b.OwnsOne("Vizhvizh.Shop.Domain.Members.ValuesObjects.MemberAvatar", "Avatar", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Members.ValuesObjects.MemberAvatar", "Avatar", b1 => { b1.Property("MemberId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Members"); b1.Property("Value") .IsRequired() @@ -523,16 +549,17 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("MemberId"); - b1.ToTable("Members", "Shop"); + b1.ToTable("Members", "GoldGallery"); b1.WithOwner() .HasForeignKey("MemberId"); }); - b.OwnsOne("Vizhvizh.Shop.Domain.Members.ValuesObjects.MemberFullName", "FullName", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Members.ValuesObjects.MemberFullName", "FullName", b1 => { b1.Property("MemberId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Members"); b1.Property("FirstName") .IsRequired() @@ -548,7 +575,26 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("MemberId"); - b1.ToTable("Members", "Shop"); + b1.ToTable("Members", "GoldGallery"); + + b1.WithOwner() + .HasForeignKey("MemberId"); + }); + + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Members.ValuesObjects.MemberNationalCode", "NationalCode", b1 => + { + b1.Property("MemberId") + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Members"); + + b1.Property("Value") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)") + .HasColumnName("NationalCode"); + + b1.HasKey("MemberId"); + + b1.ToTable("Members", "GoldGallery"); b1.WithOwner() .HasForeignKey("MemberId"); @@ -557,14 +603,23 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Navigation("Avatar"); b.Navigation("FullName"); + + b.Navigation("NationalCode"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Category", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.Category", b => { - b.OwnsOne("Vizhvizh.Shop.Domain.Products.ValuesObjects.CategoryImage", "Image", b1 => + b.HasOne("Vizhvizh.GoldGallery.Domain.Products.Entities.Category", null) + .WithMany() + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Restrict) + .HasConstraintName("FK_Categories_ParentId"); + + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.CategoryImage", "Image", b1 => { b1.Property("CategoryId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Categories"); b1.Property("Value") .IsRequired() @@ -574,7 +629,7 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("CategoryId"); - b1.ToTable("Categories", "Shop"); + b1.ToTable("Categories", "GoldGallery"); b1.WithOwner() .HasForeignKey("CategoryId"); @@ -584,54 +639,21 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.CategoryVariantUnit", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.Product", b => { - b.HasOne("Vizhvizh.Shop.Domain.Products.Entities.Category", null) - .WithMany("CategoryVariantUnits") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Vizhvizh.Shop.Domain.Products.Entities.VariantUnit", null) - .WithMany("CategoryVariantUnits") - .HasForeignKey("VariantUnitId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Product", b => - { - b.HasOne("Vizhvizh.Shop.Domain.Products.Entities.Category", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Products.Entities.Category", null) .WithMany("Products") .HasForeignKey("CategoryId"); - b.HasOne("Vizhvizh.Shop.Domain.Shops.Entities.Shop", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Shops.Entities.Shop", null) .WithMany("Products") .HasForeignKey("ShopId"); - b.OwnsOne("Vizhvizh.Shop.Domain.Products.ValuesObjects.ProductImage", "Image", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.ProductScore", "Score", b1 => { b1.Property("ProductId") - .HasColumnType("bigint"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)") - .HasColumnName("Image"); - - b1.HasKey("ProductId"); - - b1.ToTable("Products", "Shop"); - - b1.WithOwner() - .HasForeignKey("ProductId"); - }); - - b.OwnsOne("Vizhvizh.Shop.Domain.Products.ValuesObjects.ProductScore", "Score", b1 => - { - b1.Property("ProductId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Products"); b1.Property("Score") .ValueGeneratedOnAdd() @@ -646,16 +668,35 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("ProductId"); - b1.ToTable("Products", "Shop"); + b1.ToTable("Products", "GoldGallery"); b1.WithOwner() .HasForeignKey("ProductId"); }); - b.OwnsOne("Vizhvizh.Shop.Domain.Products.ValuesObjects.ProductCondition", "ProductCondition", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.CraftsmanshipFee", "CraftsmanshipFee", b1 => { b1.Property("ProductId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Products"); + + b1.Property("Value") + .HasColumnType("decimal(4,2)") + .HasColumnName("CraftsmanshipFee"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products", "GoldGallery"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.ProductCondition", "ProductCondition", b1 => + { + b1.Property("ProductId") + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Products"); b1.Property("Value") .HasColumnType("int") @@ -663,12 +704,56 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("ProductId"); - b1.ToTable("Products", "Shop"); + b1.ToTable("Products", "GoldGallery"); b1.WithOwner() .HasForeignKey("ProductId"); }); + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.ProductFile3D", "File3D", b1 => + { + b1.Property("ProductId") + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Products"); + + b1.Property("Value") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)") + .HasColumnName("File3D"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products", "GoldGallery"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.ProductImage", "Image", b1 => + { + b1.Property("ProductId") + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Products"); + + b1.Property("Value") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)") + .HasColumnName("Image"); + + b1.HasKey("ProductId"); + + b1.ToTable("Products", "GoldGallery"); + + b1.WithOwner() + .HasForeignKey("ProductId"); + }); + + b.Navigation("CraftsmanshipFee") + .IsRequired(); + + b.Navigation("File3D"); + b.Navigation("Image") .IsRequired(); @@ -679,44 +764,17 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.ProductVariant", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.ProductVariant", b => { - b.HasOne("Vizhvizh.Shop.Domain.Products.Entities.Product", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Products.Entities.Product", null) .WithMany("Variants") .HasForeignKey("ProductId"); - b.HasOne("Vizhvizh.Shop.Domain.Products.Entities.VariantUnit", null) - .WithMany("ProductVariants") - .HasForeignKey("VariantUnitId"); - - b.OwnsMany("Vizhvizh.Shop.Domain.Products.ValuesObjects.ProductImage", "Gallery", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.ProductScore", "Score", b1 => { b1.Property("ProductVariantId") - .HasColumnType("bigint"); - - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b1.Property("Value") - .IsRequired() - .HasColumnType("nvarchar(max)") - .HasColumnName("Gallery"); - - b1.HasKey("ProductVariantId", "Id"); - - b1.ToTable("ProductVariants", "Shop"); - - b1.ToJson("Gallery"); - - b1.WithOwner() - .HasForeignKey("ProductVariantId"); - }); - - b.OwnsOne("Vizhvizh.Shop.Domain.Products.ValuesObjects.ProductScore", "Score", b1 => - { - b1.Property("ProductVariantId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_ProductVariants"); b1.Property("Score") .ValueGeneratedOnAdd() @@ -732,39 +790,35 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("ProductVariantId"); - b1.ToTable("ProductVariants", "Shop"); + b1.ToTable("ProductVariants", "GoldGallery"); b1.WithOwner() .HasForeignKey("ProductVariantId"); }); - b.OwnsOne("Vizhvizh.Shop.Domain.Products.ValuesObjects.MoneyValue", "Price", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.GoldWeight", "Weight", b1 => { b1.Property("ProductVariantId") - .HasColumnType("bigint"); - - b1.Property("Currency") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)") - .HasColumnName("Currency"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_ProductVariants"); b1.Property("Value") - .HasColumnType("decimal(18,2)") - .HasColumnName("Price"); + .HasColumnType("decimal(7,3)") + .HasColumnName("Weight"); b1.HasKey("ProductVariantId"); - b1.ToTable("ProductVariants", "Shop"); + b1.ToTable("ProductVariants", "GoldGallery"); b1.WithOwner() .HasForeignKey("ProductVariantId"); }); - b.OwnsOne("Vizhvizh.Shop.Domain.Products.ValuesObjects.ProductQuantity", "Quantity", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.ProductQuantity", "Quantity", b1 => { b1.Property("ProductVariantId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_ProductVariants"); b1.Property("Value") .HasColumnType("float") @@ -772,34 +826,34 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("ProductVariantId"); - b1.ToTable("ProductVariants", "Shop"); + b1.ToTable("ProductVariants", "GoldGallery"); b1.WithOwner() .HasForeignKey("ProductVariantId"); }); - b.OwnsOne("Vizhvizh.Shop.Domain.Products.ValuesObjects.ProductVariantValue", "Value", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Products.ValuesObjects.ProductVariantGallery", "Gallery", b1 => { b1.Property("ProductVariantId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_ProductVariants"); - b1.Property("Value") + b1.Property("Values") .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)") - .HasColumnName("Value"); + .HasColumnType("nvarchar(max)") + .HasColumnName("Gallery"); b1.HasKey("ProductVariantId"); - b1.ToTable("ProductVariants", "Shop"); + b1.ToTable("ProductVariants", "GoldGallery"); + + b1.ToJson("Gallery"); b1.WithOwner() .HasForeignKey("ProductVariantId"); }); - b.Navigation("Gallery"); - - b.Navigation("Price") + b.Navigation("Gallery") .IsRequired(); b.Navigation("Quantity") @@ -808,49 +862,39 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Navigation("Score") .IsRequired(); - b.Navigation("Value") + b.Navigation("Weight") .IsRequired(); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Specifications", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.Specifications", b => { - b.HasOne("Vizhvizh.Shop.Domain.Products.Entities.Product", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Products.Entities.Product", null) .WithMany("Specifications") .HasForeignKey("ProductId"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.VariantUnit", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Shops.Entities.Management", b => { - b.HasOne("Vizhvizh.Shop.Domain.Products.Entities.Unit", null) - .WithMany("VariantUnits") - .HasForeignKey("UnitId"); - - b.HasOne("Vizhvizh.Shop.Domain.Products.Entities.Variant", null) - .WithMany("VariantUnits") - .HasForeignKey("VariantId"); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Shops.Entities.Management", b => - { - b.HasOne("Vizhvizh.Shop.Domain.Shops.Entities.Shop", "Shop") + b.HasOne("Vizhvizh.GoldGallery.Domain.Shops.Entities.Shop", "Shop") .WithOne("Management") - .HasForeignKey("Vizhvizh.Shop.Domain.Shops.Entities.Management", "Id") + .HasForeignKey("Vizhvizh.GoldGallery.Domain.Shops.Entities.Management", "Id") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Shop"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Shops.Entities.ShippingMethod", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Shops.Entities.ShippingMethod", b => { - b.HasOne("Vizhvizh.Shop.Domain.Shops.Entities.Shop", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Shops.Entities.Shop", null) .WithMany("ShippingMethods") .HasForeignKey("ShopId"); - b.OwnsOne("Vizhvizh.Shop.Domain.Shops.ValuesObjects.ShippingMethodImage", "Image", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects.ShippingMethodImage", "Image", b1 => { - b1.Property("ShippingMethodId") - .HasColumnType("tinyint"); + b1.Property("ShippingMethodId") + .HasColumnType("int") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_ShippingMethods"); b1.Property("Value") .IsRequired() @@ -860,7 +904,7 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("ShippingMethodId"); - b1.ToTable("ShippingMethods", "Shop"); + b1.ToTable("ShippingMethods", "GoldGallery"); b1.WithOwner() .HasForeignKey("ShippingMethodId"); @@ -870,12 +914,39 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Shops.Entities.Shop", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Shops.Entities.Shop", b => { - b.OwnsOne("Vizhvizh.Shop.Domain.Shops.ValuesObjects.ShopLocation", "Location", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects.ShopBusinessLicense", "BusinessLicense", b1 => { b1.Property("ShopId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Shops"); + + b1.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasColumnName("ShopBusinessLicenseCode"); + + b1.Property("Image") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)") + .HasColumnName("ShopBusinessLicenseImage"); + + b1.HasKey("ShopId"); + + b1.ToTable("Shops", "GoldGallery"); + + b1.WithOwner() + .HasForeignKey("ShopId"); + }); + + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects.ShopLocation", "Location", b1 => + { + b1.Property("ShopId") + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Shops"); b1.Property("Address") .IsRequired() @@ -905,7 +976,7 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("ShopId"); - b1.ToTable("Shops", "Shop"); + b1.ToTable("Shops", "GoldGallery"); b1.ToJson("Location"); @@ -913,10 +984,11 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .HasForeignKey("ShopId"); }); - b.OwnsOne("Vizhvizh.Shop.Domain.Shops.ValuesObjects.ShopLogo", "Logo", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Shops.ValuesObjects.ShopLogo", "Logo", b1 => { b1.Property("ShopId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Shops"); b1.Property("Value") .HasMaxLength(150) @@ -925,12 +997,15 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("ShopId"); - b1.ToTable("Shops", "Shop"); + b1.ToTable("Shops", "GoldGallery"); b1.WithOwner() .HasForeignKey("ShopId"); }); + b.Navigation("BusinessLicense") + .IsRequired(); + b.Navigation("Location") .IsRequired(); @@ -938,12 +1013,13 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Sliders.Entities.Slider", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Sliders.Entities.Slider", b => { - b.OwnsOne("Vizhvizh.Shop.Domain.Sliders.ValuesObjects.SliderImage", "Image", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Sliders.ValuesObjects.SliderImage", "Image", b1 => { b1.Property("SliderId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Sliders"); b1.Property("Value") .IsRequired() @@ -953,16 +1029,17 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("SliderId"); - b1.ToTable("Sliders", "Shop"); + b1.ToTable("Sliders", "GoldGallery"); b1.WithOwner() .HasForeignKey("SliderId"); }); - b.OwnsOne("Vizhvizh.Shop.Domain.Sliders.ValuesObjects.SliderKey", "Key", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Sliders.ValuesObjects.SliderKey", "Key", b1 => { b1.Property("SliderId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Sliders"); b1.Property("Type") .HasColumnType("INT") @@ -976,16 +1053,17 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("SliderId"); - b1.ToTable("Sliders", "Shop"); + b1.ToTable("Sliders", "GoldGallery"); b1.WithOwner() .HasForeignKey("SliderId"); }); - b.OwnsOne("Vizhvizh.Shop.Domain.Sliders.ValuesObjects.SliderUrl", "Url", b1 => + b.OwnsOne("Vizhvizh.GoldGallery.Domain.Sliders.ValuesObjects.SliderUrl", "Url", b1 => { b1.Property("SliderId") - .HasColumnType("bigint"); + .HasColumnType("bigint") + .HasAnnotation("SqlServer:HiLoSequenceName", "Sequence_Sliders"); b1.Property("Value") .IsRequired() @@ -995,7 +1073,7 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b1.HasKey("SliderId"); - b1.ToTable("Sliders", "Shop"); + b1.ToTable("Sliders", "GoldGallery"); b1.WithOwner() .HasForeignKey("SliderId"); @@ -1011,56 +1089,37 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.Role", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.Role", b => { - b.HasOne("Vizhvizh.Shop.Domain.Users.Entities.Resource", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Users.Entities.Resource", null) .WithMany("Roles") .HasForeignKey("ResourceId"); - b.HasOne("Vizhvizh.Shop.Domain.Users.Entities.User", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Users.Entities.User", null) .WithMany("Roles") .HasForeignKey("UserId"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.RoleResource", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.RoleResource", b => { - b.HasOne("Vizhvizh.Shop.Domain.Users.Entities.Role", null) + b.HasOne("Vizhvizh.GoldGallery.Domain.Users.Entities.Role", null) .WithMany("RoleResources") .HasForeignKey("RoleId"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Category", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.Category", b => { - b.Navigation("CategoryVariantUnits"); - b.Navigation("Products"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Product", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Products.Entities.Product", b => { b.Navigation("Specifications"); b.Navigation("Variants"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Unit", b => - { - b.Navigation("VariantUnits"); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.Variant", b => - { - b.Navigation("VariantUnits"); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Products.Entities.VariantUnit", b => - { - b.Navigation("CategoryVariantUnits"); - - b.Navigation("ProductVariants"); - }); - - modelBuilder.Entity("Vizhvizh.Shop.Domain.Shops.Entities.Shop", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Shops.Entities.Shop", b => { b.Navigation("Management") .IsRequired(); @@ -1072,17 +1131,17 @@ namespace Vizhvizh.Shop.Infrastructure.Migrations b.Navigation("ShippingMethods"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.Resource", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.Resource", b => { b.Navigation("Roles"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.Role", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.Role", b => { b.Navigation("RoleResources"); }); - modelBuilder.Entity("Vizhvizh.Shop.Domain.Users.Entities.User", b => + modelBuilder.Entity("Vizhvizh.GoldGallery.Domain.Users.Entities.User", b => { b.Navigation("Roles"); }); diff --git a/Vizhvizh.GoldGallery.Infrastructure/Repositories/CategoryRepository.cs b/Vizhvizh.GoldGallery.Infrastructure/Repositories/CategoryRepository.cs new file mode 100644 index 0000000..d9e695f --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/Repositories/CategoryRepository.cs @@ -0,0 +1,12 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.BuildingBlocks.Infrastructure.Lifetimes; +using Vizhvizh.GoldGallery.Domain.Products.Entities; +using Vizhvizh.GoldGallery.Domain.Products.Repositories; +using Vizhvizh.GoldGallery.Domain.Products.TypeIds; +using Vizhvizh.GoldGallery.Infrastructure.EF; + +namespace Vizhvizh.GoldGallery.Infrastructure.Repositories; + +internal class CategoryRepository(GoldGalleryDbContext context) : RepositoryBase(context), ICategoryRepository, IScopeDependency +{ +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/Repositories/ProductRepository.cs b/Vizhvizh.GoldGallery.Infrastructure/Repositories/ProductRepository.cs new file mode 100644 index 0000000..d71ac0a --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/Repositories/ProductRepository.cs @@ -0,0 +1,12 @@ +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.BuildingBlocks.Infrastructure.Lifetimes; +using Vizhvizh.GoldGallery.Domain.Products.Entities; +using Vizhvizh.GoldGallery.Domain.Products.Repositories; +using Vizhvizh.GoldGallery.Domain.Products.TypeIds; +using Vizhvizh.GoldGallery.Infrastructure.EF; + +namespace Vizhvizh.GoldGallery.Infrastructure.Repositories; + +internal class ProductRepository(GoldGalleryDbContext context) : RepositoryBase(context), IProductRepository, IScopeDependency +{ +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/Repositories/ShopRepository.cs b/Vizhvizh.GoldGallery.Infrastructure/Repositories/ShopRepository.cs new file mode 100644 index 0000000..e8bd059 --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/Repositories/ShopRepository.cs @@ -0,0 +1,12 @@ +using Vizhvizh.BuildingBlocks.Infrastructure.Lifetimes; +using Vizhvizh.GoldGallery.Domain.Shops.Entities; +using Vizhvizh.GoldGallery.Domain.Shops.Repositories; +using Vizhvizh.GoldGallery.Domain.Shops.TypeIds; +using Vizhvizh.GoldGallery.Infrastructure.EF; + +namespace Vizhvizh.GoldGallery.Infrastructure.Repositories +{ + internal class ShopRepository(GoldGalleryDbContext context) : RepositoryBase(context), IShopRepository, IScopeDependency + { + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/Repositories/SliderRepository.cs b/Vizhvizh.GoldGallery.Infrastructure/Repositories/SliderRepository.cs new file mode 100644 index 0000000..b2889e1 --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/Repositories/SliderRepository.cs @@ -0,0 +1,11 @@ +using Vizhvizh.BuildingBlocks.Infrastructure.Lifetimes; +using Vizhvizh.GoldGallery.Domain.Sliders.Entities; +using Vizhvizh.GoldGallery.Domain.Sliders.Repositories; +using Vizhvizh.GoldGallery.Domain.Sliders.TypeIds; +using Vizhvizh.GoldGallery.Infrastructure.EF; + +namespace Vizhvizh.GoldGallery.Infrastructure.Repositories; + +internal class SliderRepository(GoldGalleryDbContext context) : RepositoryBase(context), ISliderRepository, IScopeDependency +{ +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/RepositoryBase.cs b/Vizhvizh.GoldGallery.Infrastructure/RepositoryBase.cs new file mode 100644 index 0000000..cc0ea3f --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/RepositoryBase.cs @@ -0,0 +1,53 @@ +using Microsoft.EntityFrameworkCore; +using Vizhvizh.BuildingBlocks.Domain; +using Vizhvizh.GoldGallery.Infrastructure.EF; +using Vizhvizh.GoldGallery.Infrastructure.Exceptions; + +namespace Vizhvizh.GoldGallery.Infrastructure; + +internal class RepositoryBase : IRepositoryBase + where T : Entity where TId : ITypeIdValueBase +{ + private readonly GoldGalleryDbContext _goldGalleryDbContext; + + public RepositoryBase(GoldGalleryDbContext goldGalleryDbContext) + { + this._goldGalleryDbContext = goldGalleryDbContext; + } + + public async Task AddAsync(T entity, CancellationToken cancellationToken) + { + await _goldGalleryDbContext.AddAsync(entity, cancellationToken); + } + + public async Task DeleteAsync(TId id, CancellationToken cancellationToken) + { + var entity = await FindByIdAsync(id, cancellationToken); + if (entity == null) + throw new EntityNotFoundException(); + + _goldGalleryDbContext.Remove(entity); + } + + public Task DeleteAsync(T entity, CancellationToken cancellationToken) + { + _goldGalleryDbContext.Remove(entity); + + return Task.CompletedTask; + } + + public async Task FindByIdAsync(TId id, CancellationToken cancellationToken) + { + var entity = _goldGalleryDbContext.Set(); + return await entity.FindAsync(id, cancellationToken); + } + + public IQueryable GetQueryAsNoTracking() + => _goldGalleryDbContext.Set().AsNoTracking(); + + public Task UpdateAsync(T entity, CancellationToken cancellationToken) + { + _goldGalleryDbContext.Update(entity); + return Task.CompletedTask; + } +} diff --git a/Vizhvizh.GoldGallery.Infrastructure/Vizhvizh.GoldGallery.Infrastructure.csproj b/Vizhvizh.GoldGallery.Infrastructure/Vizhvizh.GoldGallery.Infrastructure.csproj new file mode 100644 index 0000000..0e15d4e --- /dev/null +++ b/Vizhvizh.GoldGallery.Infrastructure/Vizhvizh.GoldGallery.Infrastructure.csproj @@ -0,0 +1,23 @@ + + + + net8.0 + enable + enable + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/Vizhvizh.sln b/Vizhvizh.sln index 6bcf786..b233aa4 100644 --- a/Vizhvizh.sln +++ b/Vizhvizh.sln @@ -95,6 +95,28 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vizhvizh.Shared.Infrastruct EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vizhvizh.Shared.Application", "Vichvich.Shared.Application\Vizhvizh.Shared.Application.csproj", "{54310E26-B264-42EE-8D53-CE490133F4FC}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GoldGallery", "GoldGallery", "{D6F29C1F-0C2F-4744-BFD2-2C5A6BA247D7}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{85E43CAD-EF4C-4F7C-B5B4-F15D70070D72}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{D4B44C43-6C5B-465B-BC20-DDF3DCEB0E9C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastructure", "{0AC103A7-51C7-49C4-BB4B-8699DF011ABC}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{BF49E7F0-9910-433D-9F81-A9189809A6C1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vizhvizh.GoldGallery.Application", "Vizhvizh.GoldGallery.Application\Vizhvizh.GoldGallery.Application.csproj", "{C88D3C97-4DAB-41F2-826E-97A6B01C52E6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vizhvizh.GoldGallery.ApplicationContract", "Vizhvizh.GoldGallery.ApplicationContract\Vizhvizh.GoldGallery.ApplicationContract.csproj", "{B3A9F098-E7D9-4546-B963-6AEE9EDB0E9C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vizhvizh.GoldGallery.Domain", "Vizhvizh.GoldGallery.Domain\Vizhvizh.GoldGallery.Domain.csproj", "{CD727285-1892-4EBA-9FBC-B36BF7FA7324}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vizhvizh.GoldGallery.Infrastructure", "Vizhvizh.GoldGallery.Infrastructure\Vizhvizh.GoldGallery.Infrastructure.csproj", "{D7F2A6A2-89B2-4580-A8E9-1FA679801B88}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vizhvizh.GoldGallery.Api", "Vizhvizh.GoldGallery.Api\Vizhvizh.GoldGallery.Api.csproj", "{1FE03FA4-7B19-4A31-80DD-B8AE2BA198E4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vizhvizh.GoldGallery.Domain.Resource", "Vizhvizh.GoldGallery.Domain.Resource\Vizhvizh.GoldGallery.Domain.Resource.csproj", "{17F8E02D-85B6-41FC-8D18-F36AD70B787A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -181,6 +203,30 @@ Global {54310E26-B264-42EE-8D53-CE490133F4FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {54310E26-B264-42EE-8D53-CE490133F4FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {54310E26-B264-42EE-8D53-CE490133F4FC}.Release|Any CPU.Build.0 = Release|Any CPU + {C88D3C97-4DAB-41F2-826E-97A6B01C52E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C88D3C97-4DAB-41F2-826E-97A6B01C52E6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C88D3C97-4DAB-41F2-826E-97A6B01C52E6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C88D3C97-4DAB-41F2-826E-97A6B01C52E6}.Release|Any CPU.Build.0 = Release|Any CPU + {B3A9F098-E7D9-4546-B963-6AEE9EDB0E9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B3A9F098-E7D9-4546-B963-6AEE9EDB0E9C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B3A9F098-E7D9-4546-B963-6AEE9EDB0E9C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B3A9F098-E7D9-4546-B963-6AEE9EDB0E9C}.Release|Any CPU.Build.0 = Release|Any CPU + {CD727285-1892-4EBA-9FBC-B36BF7FA7324}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CD727285-1892-4EBA-9FBC-B36BF7FA7324}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CD727285-1892-4EBA-9FBC-B36BF7FA7324}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CD727285-1892-4EBA-9FBC-B36BF7FA7324}.Release|Any CPU.Build.0 = Release|Any CPU + {D7F2A6A2-89B2-4580-A8E9-1FA679801B88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7F2A6A2-89B2-4580-A8E9-1FA679801B88}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D7F2A6A2-89B2-4580-A8E9-1FA679801B88}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D7F2A6A2-89B2-4580-A8E9-1FA679801B88}.Release|Any CPU.Build.0 = Release|Any CPU + {1FE03FA4-7B19-4A31-80DD-B8AE2BA198E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1FE03FA4-7B19-4A31-80DD-B8AE2BA198E4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1FE03FA4-7B19-4A31-80DD-B8AE2BA198E4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1FE03FA4-7B19-4A31-80DD-B8AE2BA198E4}.Release|Any CPU.Build.0 = Release|Any CPU + {17F8E02D-85B6-41FC-8D18-F36AD70B787A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {17F8E02D-85B6-41FC-8D18-F36AD70B787A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {17F8E02D-85B6-41FC-8D18-F36AD70B787A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {17F8E02D-85B6-41FC-8D18-F36AD70B787A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -228,6 +274,17 @@ Global {BB74BFF4-131B-4BAE-9345-6043C15F97F6} = {D90687B2-3CF8-4E5A-A2F2-780EB843BCBE} {503F6D97-9DDF-44B0-A861-F532A81D3BAC} = {E50B8541-6FF2-4B56-907B-2F7584EBC3E7} {54310E26-B264-42EE-8D53-CE490133F4FC} = {DC8302F3-1358-498E-9F91-1BFAC45026D9} + {D6F29C1F-0C2F-4744-BFD2-2C5A6BA247D7} = {64F8E6C2-F045-4974-86B2-35E63072093D} + {85E43CAD-EF4C-4F7C-B5B4-F15D70070D72} = {D6F29C1F-0C2F-4744-BFD2-2C5A6BA247D7} + {D4B44C43-6C5B-465B-BC20-DDF3DCEB0E9C} = {D6F29C1F-0C2F-4744-BFD2-2C5A6BA247D7} + {0AC103A7-51C7-49C4-BB4B-8699DF011ABC} = {D6F29C1F-0C2F-4744-BFD2-2C5A6BA247D7} + {BF49E7F0-9910-433D-9F81-A9189809A6C1} = {D6F29C1F-0C2F-4744-BFD2-2C5A6BA247D7} + {C88D3C97-4DAB-41F2-826E-97A6B01C52E6} = {85E43CAD-EF4C-4F7C-B5B4-F15D70070D72} + {B3A9F098-E7D9-4546-B963-6AEE9EDB0E9C} = {85E43CAD-EF4C-4F7C-B5B4-F15D70070D72} + {CD727285-1892-4EBA-9FBC-B36BF7FA7324} = {D4B44C43-6C5B-465B-BC20-DDF3DCEB0E9C} + {D7F2A6A2-89B2-4580-A8E9-1FA679801B88} = {0AC103A7-51C7-49C4-BB4B-8699DF011ABC} + {1FE03FA4-7B19-4A31-80DD-B8AE2BA198E4} = {BF49E7F0-9910-433D-9F81-A9189809A6C1} + {17F8E02D-85B6-41FC-8D18-F36AD70B787A} = {7C23B8CD-8B5A-4968-8383-83D26A0B1751} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7AC6F270-5F8A-4E0F-BF79-F0FF567D4C34}