.
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace VizhTalk.BuildingBlocks.Domain;
|
||||
|
||||
public abstract class TypedIdValueBase<T> : IEquatable<TypedIdValueBase<T>>, ITypeIdValueBase
|
||||
public abstract class TypeIdValueBase<T> : IEquatable<TypeIdValueBase<T>>, ITypeIdValueBase
|
||||
{
|
||||
public T Value { get; }
|
||||
|
||||
protected TypedIdValueBase(T value)
|
||||
protected TypeIdValueBase(T value)
|
||||
{
|
||||
|
||||
if (EqualityComparer<T>.Default.Equals(value, default(T)))
|
||||
@@ -22,7 +22,7 @@ public abstract class TypedIdValueBase<T> : IEquatable<TypedIdValueBase<T>>, ITy
|
||||
if (ReferenceEquals(null, obj))
|
||||
return false;
|
||||
|
||||
return obj is TypedIdValueBase<T> other && Equals(other);
|
||||
return obj is TypeIdValueBase<T> other && Equals(other);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
@@ -30,7 +30,7 @@ public abstract class TypedIdValueBase<T> : IEquatable<TypedIdValueBase<T>>, ITy
|
||||
return Value!.GetHashCode();
|
||||
}
|
||||
|
||||
public bool Equals(TypedIdValueBase<T>? other)
|
||||
public bool Equals(TypeIdValueBase<T>? other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
@@ -39,7 +39,7 @@ public abstract class TypedIdValueBase<T> : IEquatable<TypedIdValueBase<T>>, ITy
|
||||
}
|
||||
|
||||
|
||||
public static bool operator ==(TypedIdValueBase<T>? obj1, TypedIdValueBase<T>? obj2)
|
||||
public static bool operator ==(TypeIdValueBase<T>? obj1, TypeIdValueBase<T>? obj2)
|
||||
{
|
||||
if (object.Equals(obj1, null))
|
||||
{
|
||||
@@ -54,7 +54,7 @@ public abstract class TypedIdValueBase<T> : IEquatable<TypedIdValueBase<T>>, ITy
|
||||
return obj1.Equals(obj2);
|
||||
}
|
||||
|
||||
public static bool operator !=(TypedIdValueBase<T>? x, TypedIdValueBase<T>? y)
|
||||
public static bool operator !=(TypeIdValueBase<T>? x, TypeIdValueBase<T>? y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ namespace VizhTalk.BuildingBlocks.Infrastructure.EF.Helpers
|
||||
}
|
||||
public static ModelBuilder PluralizeEntities(this ModelBuilder modelBuilder)
|
||||
{
|
||||
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
|
||||
var entities = modelBuilder.Model.GetEntityTypes().Where(x => !x.IsKeyless && !x.IsOwned());
|
||||
foreach (var entityType in entities)
|
||||
{
|
||||
entityType.SetTableName(entityType.DisplayName().Pluralize());
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using VizhTalk.BuildingBlocks.Application.Configuration.Commnad;
|
||||
using VizhTalk.BuildingBlocks.Application.Exceptions;
|
||||
using VizhTalk.BuildingBlocks.Domain.Contract;
|
||||
using VizhTalk.Grpc.CDN;
|
||||
using VizhTalk.Grpc.Learning;
|
||||
using VizhTalk.Grpc.Learning.Language;
|
||||
using VizhTalk.Learning.Application.Exceptions;
|
||||
@@ -11,7 +12,7 @@ using VizhTalk.Learning.Domain.ValueObjects;
|
||||
|
||||
namespace VizhTalk.Learning.Application.CommandHandlers;
|
||||
|
||||
public class CreateLanguageCommandHandler(IUnitOfWork unitOfWork) : ICommandHandler<CreateLanguageCommand, LanguageDTO>
|
||||
public class CreateLanguageCommandHandler(IUnitOfWork unitOfWork, CDNGrpc.CDNGrpcClient cdnClient) : ICommandHandler<CreateLanguageCommand, LanguageDTO>
|
||||
{
|
||||
public async Task<LanguageDTO> Handle(CreateLanguageCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -19,7 +20,8 @@ public class CreateLanguageCommandHandler(IUnitOfWork unitOfWork) : ICommandHand
|
||||
if (await unitOfWork.Language.Exists(x => x.Title == title))
|
||||
throw new LanguageTitleAlreadyExistsException();
|
||||
|
||||
var language = Language.CreateNew(new LanguageTitle(title));
|
||||
|
||||
var language = Language.CreateNew(new LanguageTitle(title), null);
|
||||
await unitOfWork.Language.AddAsync(language, cancellationToken);
|
||||
await unitOfWork.SaveChangeAsync(cancellationToken);
|
||||
return language.Adapt<LanguageDTO>();
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VizhTalk.BuildingBlocks.Application\VizhTalk.BuildingBlocks.Application.csproj" />
|
||||
<ProjectReference Include="..\VizhTalk.Grpc.CDN\VizhTalk.Grpc.CDN.csproj" />
|
||||
<ProjectReference Include="..\VizhTalk.Learning.Domain\VizhTalk.Learning.Domain.csproj" />
|
||||
<ProjectReference Include="..\VizhTalk.Services.Grpc.Learning\VizhTalk.Grpc.Learning.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using VizhTalk.BuildingBlocks.Domain;
|
||||
using VizhTalk.Learning.Domain.TypeIds;
|
||||
using VizhTalk.Learning.Domain.ValueObjects;
|
||||
|
||||
namespace VizhTalk.Learning.Domain.Entities;
|
||||
|
||||
public class FileGroup : Entity<FileGroupId>
|
||||
{
|
||||
public FileGroup()
|
||||
{
|
||||
|
||||
}
|
||||
private FileGroup(FileGroupKey key,
|
||||
FileGroupTitle title,
|
||||
bool isSecure,
|
||||
long mediaGroupId)
|
||||
{
|
||||
Title = title;
|
||||
MediaGroupId = mediaGroupId;
|
||||
Key = key;
|
||||
IsSecure = isSecure;
|
||||
}
|
||||
public FileGroupTitle Title { get; set; }
|
||||
public FileGroupKey Key { get; private set; }
|
||||
public long MediaGroupId { get; private set; }
|
||||
public bool IsSecure { get; set; }
|
||||
|
||||
public static FileGroup CreateNew(FileGroupKey key,
|
||||
FileGroupTitle title,
|
||||
bool isSecure,
|
||||
long mediaGroupId)
|
||||
=> new(key,title, isSecure, mediaGroupId);
|
||||
}
|
||||
@@ -10,15 +10,20 @@ public class Language : Entity<LanguageId>, IAggregateRoot
|
||||
{
|
||||
// only EF
|
||||
}
|
||||
private Language(LanguageTitle title)
|
||||
private Language(LanguageTitle title, Media icon)
|
||||
{
|
||||
Title = title;
|
||||
Icon = icon;
|
||||
|
||||
}
|
||||
public LanguageTitle Title { get; private set; }
|
||||
public Media Icon { get; private set; }
|
||||
|
||||
public static Language CreateNew(LanguageTitle title)
|
||||
=> new(title);
|
||||
public static Language CreateNew(LanguageTitle title,Media icon)
|
||||
=> new(title, icon);
|
||||
|
||||
public void SetTitle(LanguageTitle title)
|
||||
=> Title = title;
|
||||
public void SetIcon(Media icon)
|
||||
=> Icon = icon;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using VizhTalk.BuildingBlocks.Domain;
|
||||
using VizhTalk.Learning.Domain.TypeIds;
|
||||
using VizhTalk.Learning.Domain.ValueObjects;
|
||||
|
||||
namespace VizhTalk.Learning.Domain.Entities;
|
||||
|
||||
public class Media : Entity<MediaId>
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public string ContentType { get; private set; }
|
||||
public int Size { get; private set; }
|
||||
public EntityType EntityType { get; private set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using VizhTalk.BuildingBlocks.Domain;
|
||||
|
||||
namespace VizhTalk.Learning.Domain.TypeIds;
|
||||
|
||||
public class FileGroupId : TypeIdValueBase<long>
|
||||
{
|
||||
public FileGroupId(long value) : base(value)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,9 @@ using VizhTalk.BuildingBlocks.Domain;
|
||||
|
||||
namespace VizhTalk.Learning.Domain.TypeIds
|
||||
{
|
||||
public class LanguageId : TypedIdValueBase<int>
|
||||
public class LanguageId : TypeIdValueBase<short>
|
||||
{
|
||||
public LanguageId(int value) : base(value)
|
||||
public LanguageId(short value) : base(value)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using VizhTalk.BuildingBlocks.Domain;
|
||||
|
||||
namespace VizhTalk.Learning.Domain.TypeIds;
|
||||
|
||||
public class MediaId : TypeIdValueBase<Guid>
|
||||
{
|
||||
public MediaId(Guid value) : base(value)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using VizhTalk.BuildingBlocks.Domain;
|
||||
|
||||
namespace VizhTalk.Learning.Domain.ValueObjects;
|
||||
|
||||
public class EntityType : ValueObject
|
||||
{
|
||||
public EntityType(string entityId, EntityTypeEnum type)
|
||||
{
|
||||
EntityId = entityId;
|
||||
Type = type;
|
||||
}
|
||||
public string EntityId { get; private set; }
|
||||
public EntityTypeEnum Type { get; private set; }
|
||||
}
|
||||
public enum EntityTypeEnum
|
||||
{
|
||||
Language = 0
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VizhTalk.BuildingBlocks.Domain;
|
||||
using VizhTalk.BuildingBlocks.Domain.Guards;
|
||||
|
||||
namespace VizhTalk.Learning.Domain.ValueObjects
|
||||
{
|
||||
public class FileGroupKey : ValueObject
|
||||
{
|
||||
public static FileGroupKey LanguageIcon = new("Language");
|
||||
public FileGroupKey(string entityName, string? entityId = null)
|
||||
{
|
||||
Guard.NullOrEmpty(entityName, entityName);
|
||||
Guard.MaxLength(entityName, entityName, 30);
|
||||
if (entityId != null)
|
||||
Value = $"VizhTalk.Learning.{entityName}.{entityId}";
|
||||
else
|
||||
Value = $"VizhTalk.Learning.{entityName}";
|
||||
}
|
||||
public string Value { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using VizhTalk.BuildingBlocks.Domain.Guards;
|
||||
using VizhTalk.BuildingBlocks.Domain;
|
||||
|
||||
namespace VizhTalk.Learning.Domain.ValueObjects;
|
||||
|
||||
public class FileGroupTitle : ValueObject
|
||||
{
|
||||
public FileGroupTitle(string value)
|
||||
{
|
||||
Guard.NullOrEmpty(value, nameof(FileGroupTitle));
|
||||
Guard.MaxLength(value, nameof(FileGroupTitle), 50);
|
||||
}
|
||||
public string Value { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using VizhTalk.Learning.Domain.Entities;
|
||||
using VizhTalk.Learning.Domain.ValueObjects;
|
||||
|
||||
namespace VizhTalk.Learning.Infrastructure.EF.Configurations;
|
||||
|
||||
internal class FileGroupConfiguration : IEntityTypeConfiguration<FileGroup>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<FileGroup> builder)
|
||||
{
|
||||
builder.ToTable(nameof(FileGroup), Schema.Attachment);
|
||||
builder.HasKey(x => x.Id);
|
||||
|
||||
builder.Property(x => x.Id)
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasConversion(x => x.Value, x => new Domain.TypeIds.FileGroupId(x));
|
||||
builder.Property(x => x.Title)
|
||||
.HasColumnName("Title")
|
||||
.HasConversion(x => x.Value, x => new FileGroupTitle(x));
|
||||
|
||||
builder.Property(x => x.Key)
|
||||
.HasColumnName("Key")
|
||||
.HasMaxLength(150)
|
||||
.HasConversion(x => x.Value, x => new FileGroupKey(x, null));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using VizhTalk.Learning.Domain.Entities;
|
||||
|
||||
namespace VizhTalk.Learning.Infrastructure.EF.Configurations;
|
||||
|
||||
internal class MediaConfiguration : IEntityTypeConfiguration<Media>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Media> builder)
|
||||
{
|
||||
builder.ToTable(nameof(Media), Schema.Learning);
|
||||
builder.HasKey(x => x.Id);
|
||||
|
||||
builder.Property(x => x.Id)
|
||||
.HasConversion(x => x.Value, x => new Domain.TypeIds.MediaId(x));
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(150);
|
||||
|
||||
builder.OwnsOne(x => x.EntityType, op =>
|
||||
{
|
||||
op.WithOwner();
|
||||
|
||||
op.Property(x => x.Type)
|
||||
.HasColumnName("EntityType")
|
||||
.HasMaxLength(200);
|
||||
|
||||
op.Property(x => x.EntityId)
|
||||
.HasColumnName("EntityId")
|
||||
.HasMaxLength(50);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,6 @@ namespace VizhTalk.Learning.Infrastructure.EF
|
||||
public class Schema
|
||||
{
|
||||
public const string Learning = "Learning";
|
||||
|
||||
public const string Attachment = "Attachment";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ using VizhTalk.BuildingBlocks.Application.Events;
|
||||
using VizhTalk.BuildingBlocks.Application.Outbox;
|
||||
using VizhTalk.BuildingBlocks.Infrastructure;
|
||||
using VizhTalk.BuildingBlocks.Infrastructure.DomainEventsDispatching;
|
||||
using VizhTalk.Grpc.CDN;
|
||||
using VizhTalk.Learning.Application;
|
||||
using VizhTalk.Learning.Application.Mappers;
|
||||
using VizhTalk.Learning.Infrastructure.Configuration;
|
||||
@@ -57,6 +58,11 @@ public static class LearningStartup
|
||||
|
||||
MapperConfig.Process();
|
||||
|
||||
services.AddGrpcClient<CDNGrpc.CDNGrpcClient>(op =>
|
||||
{
|
||||
op.Address = new Uri("https://localhost:5001");
|
||||
});
|
||||
|
||||
services.AddScoped(sa =>
|
||||
{
|
||||
var notifications = sa.GetServices<IDomainEventNotification>();
|
||||
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
// <auto-generated />
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using VizhTalk.Learning.Infrastructure.EF;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace VizhTalk.Learning.Infrastructure.Migrations
|
||||
{
|
||||
[DbContext(typeof(LearningDbContext))]
|
||||
[Migration("20250902200044_Inital")]
|
||||
partial class Inital
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasDefaultSchema("Learning")
|
||||
.HasAnnotation("ProductVersion", "8.0.19")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("IsDeleted")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(60)
|
||||
.HasColumnType("nvarchar(60)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Languages", "Learning");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace VizhTalk.Learning.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Inital : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.EnsureSchema(
|
||||
name: "Learning");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Languages",
|
||||
schema: "Learning",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Title = table.Column<string>(type: "nvarchar(60)", maxLength: 60, nullable: false),
|
||||
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
|
||||
IsActive = table.Column<bool>(type: "bit", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Languages", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Languages",
|
||||
schema: "Learning");
|
||||
}
|
||||
}
|
||||
}
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using VizhTalk.Learning.Infrastructure.EF;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace VizhTalk.Learning.Infrastructure.Migrations
|
||||
{
|
||||
[DbContext(typeof(LearningDbContext))]
|
||||
[Migration("20250905153842_initial")]
|
||||
partial class initial
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasDefaultSchema("Learning")
|
||||
.HasAnnotation("ProductVersion", "8.0.19")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.FileGroup", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreateOn")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("IsDeleted")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("IsSecure")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("Key")
|
||||
.IsRequired()
|
||||
.HasMaxLength(150)
|
||||
.HasColumnType("nvarchar(150)")
|
||||
.HasColumnName("Key");
|
||||
|
||||
b.Property<DateTime>("LastUpdate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<long>("MediaGroupId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)")
|
||||
.HasColumnName("Title");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("FileGroups", "Attachment");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
|
||||
{
|
||||
b.Property<short>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("smallint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<short>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreateOn")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("IconId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("IsDeleted")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTime>("LastUpdate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(60)
|
||||
.HasColumnType("nvarchar(60)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IconId");
|
||||
|
||||
b.ToTable("Languages", "Learning");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Media", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("CreateOn")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("IsDeleted")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTime>("LastUpdate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(150)
|
||||
.HasColumnType("nvarchar(150)");
|
||||
|
||||
b.Property<int>("Size")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Medias", "Learning");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
|
||||
{
|
||||
b.HasOne("VizhTalk.Learning.Domain.Entities.Media", "Icon")
|
||||
.WithMany()
|
||||
.HasForeignKey("IconId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Icon");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Media", b =>
|
||||
{
|
||||
b.OwnsOne("VizhTalk.Learning.Domain.ValueObjects.EntityType", "EntityType", b1 =>
|
||||
{
|
||||
b1.Property<Guid>("MediaId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b1.Property<string>("EntityId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("EntityId");
|
||||
|
||||
b1.Property<int>("Type")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("EntityType");
|
||||
|
||||
b1.HasKey("MediaId");
|
||||
|
||||
b1.ToTable("Medias", "Learning");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("MediaId");
|
||||
});
|
||||
|
||||
b.Navigation("EntityType")
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace VizhTalk.Learning.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class initial : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.EnsureSchema(
|
||||
name: "Attachment");
|
||||
|
||||
migrationBuilder.EnsureSchema(
|
||||
name: "Learning");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "FileGroups",
|
||||
schema: "Attachment",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Key = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: false),
|
||||
MediaGroupId = table.Column<long>(type: "bigint", nullable: false),
|
||||
IsSecure = table.Column<bool>(type: "bit", nullable: false),
|
||||
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
|
||||
IsActive = table.Column<bool>(type: "bit", nullable: false),
|
||||
CreateOn = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
LastUpdate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_FileGroups", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Medias",
|
||||
schema: "Learning",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Name = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: false),
|
||||
ContentType = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Size = table.Column<int>(type: "int", nullable: false),
|
||||
EntityId = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
||||
EntityType = table.Column<int>(type: "int", maxLength: 200, nullable: false),
|
||||
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
|
||||
IsActive = table.Column<bool>(type: "bit", nullable: false),
|
||||
CreateOn = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
LastUpdate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Medias", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Languages",
|
||||
schema: "Learning",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<short>(type: "smallint", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Title = table.Column<string>(type: "nvarchar(60)", maxLength: 60, nullable: false),
|
||||
IconId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
|
||||
IsActive = table.Column<bool>(type: "bit", nullable: false),
|
||||
CreateOn = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
LastUpdate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Languages", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Languages_Medias_IconId",
|
||||
column: x => x.IconId,
|
||||
principalSchema: "Learning",
|
||||
principalTable: "Medias",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Languages_IconId",
|
||||
schema: "Learning",
|
||||
table: "Languages",
|
||||
column: "IconId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "FileGroups",
|
||||
schema: "Attachment");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Languages",
|
||||
schema: "Learning");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Medias",
|
||||
schema: "Learning");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
@@ -22,13 +23,16 @@ namespace VizhTalk.Learning.Infrastructure.Migrations
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
|
||||
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.FileGroup", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreateOn")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("bit");
|
||||
@@ -36,6 +40,54 @@ namespace VizhTalk.Learning.Infrastructure.Migrations
|
||||
b.Property<bool>("IsDeleted")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("IsSecure")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("Key")
|
||||
.IsRequired()
|
||||
.HasMaxLength(150)
|
||||
.HasColumnType("nvarchar(150)")
|
||||
.HasColumnName("Key");
|
||||
|
||||
b.Property<DateTime>("LastUpdate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<long>("MediaGroupId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)")
|
||||
.HasColumnName("Title");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("FileGroups", "Attachment");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
|
||||
{
|
||||
b.Property<short>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("smallint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<short>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreateOn")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("IconId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("IsDeleted")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTime>("LastUpdate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(60)
|
||||
@@ -43,8 +95,85 @@ namespace VizhTalk.Learning.Infrastructure.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IconId");
|
||||
|
||||
b.ToTable("Languages", "Learning");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Media", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("CreateOn")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("IsDeleted")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTime>("LastUpdate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(150)
|
||||
.HasColumnType("nvarchar(150)");
|
||||
|
||||
b.Property<int>("Size")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Medias", "Learning");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
|
||||
{
|
||||
b.HasOne("VizhTalk.Learning.Domain.Entities.Media", "Icon")
|
||||
.WithMany()
|
||||
.HasForeignKey("IconId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Icon");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Media", b =>
|
||||
{
|
||||
b.OwnsOne("VizhTalk.Learning.Domain.ValueObjects.EntityType", "EntityType", b1 =>
|
||||
{
|
||||
b1.Property<Guid>("MediaId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b1.Property<string>("EntityId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("EntityId");
|
||||
|
||||
b1.Property<int>("Type")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("EntityType");
|
||||
|
||||
b1.HasKey("MediaId");
|
||||
|
||||
b1.ToTable("Medias", "Learning");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("MediaId");
|
||||
});
|
||||
|
||||
b.Navigation("EntityType")
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.1.66" />
|
||||
<PackageReference Include="Grpc.AspNetCore" Version="2.57.0" />
|
||||
<PackageReference Include="Dapper" Version="2.1.66" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.19">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Grpc.AspNetCore" Version="2.57.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.19">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
||||
@@ -22,10 +22,15 @@ public sealed partial class Id
|
||||
public static implicit operator long(Id id)
|
||||
=> long.Parse(EncryptionIdHelper.Decrypt(id.Value));
|
||||
|
||||
public static implicit operator short(Id id)
|
||||
=> short.Parse(EncryptionIdHelper.Decrypt(id.Value));
|
||||
|
||||
public static implicit operator Id(int id)
|
||||
=> (Id)id.ToString();
|
||||
|
||||
public static implicit operator Id(short id)
|
||||
=> (Id)id.ToString();
|
||||
|
||||
public static implicit operator Id(long id)
|
||||
=> (Id)id.ToString();
|
||||
|
||||
|
||||
@@ -7,10 +7,12 @@ import "Proto/Shared.proto";
|
||||
|
||||
|
||||
message CreateLanguageCommand{
|
||||
string title = 2;
|
||||
string title = 1;
|
||||
bytes icon = 2;
|
||||
}
|
||||
|
||||
message UpdateLanguageCommand{
|
||||
Id Id = 1;
|
||||
string title = 2;
|
||||
bytes icon = 3;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:11814",
|
||||
"applicationUrl": "http://localhost:5001",
|
||||
"sslPort": 44357
|
||||
}
|
||||
},
|
||||
@@ -13,7 +13,7 @@
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "http://localhost:5041",
|
||||
"applicationUrl": "http://localhost:5001",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
@@ -22,7 +22,7 @@
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7109;http://localhost:5041",
|
||||
"applicationUrl": "https://localhost:5001",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user