diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Database/Schemas/DepartmentSchema.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Database/Schemas/DepartmentSchema.cs index ec5be36..8c73f02 100644 --- a/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Database/Schemas/DepartmentSchema.cs +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Database/Schemas/DepartmentSchema.cs @@ -10,6 +10,5 @@ namespace EasyMicroservices.SupportsMicroservice.Database.Schemas { public class DepartmentSchema : FullAbilitySchema { - public string Title { get; set; } } } diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Database/Schemas/TicketHistorySchema.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Database/Schemas/TicketHistorySchema.cs index e363da6..72057f1 100644 --- a/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Database/Schemas/TicketHistorySchema.cs +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Database/Schemas/TicketHistorySchema.cs @@ -10,6 +10,5 @@ namespace EasyMicroservices.SupportsMicroservice.Database.Schemas { public class TicketHistorySchema : FullAbilitySchema { - public string Content { get; set; } } } diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Migrations/20231130075023_Delete_Title.Designer.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Migrations/20231130075023_Delete_Title.Designer.cs new file mode 100644 index 0000000..bf21da9 --- /dev/null +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Migrations/20231130075023_Delete_Title.Designer.cs @@ -0,0 +1,438 @@ +// +using System; +using EasyMicroservices.SupportsMicroservice.Database.Contexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EasyMicroservices.SupportsMicroservice.Migrations +{ + [DbContext(typeof(SupportContext))] + [Migration("20231130075023_Delete_Title")] + partial class Delete_Title + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EasyMicroservices.SupportsMicroservice.Database.Entities.DepartmentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreationDateTime") + .HasColumnType("datetime2"); + + b.Property("DeletedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModificationDateTime") + .HasColumnType("datetime2"); + + b.Property("UniqueIdentity") + .HasColumnType("nvarchar(450)") + .UseCollation("SQL_Latin1_General_CP1_CS_AS"); + + b.HasKey("Id"); + + b.HasIndex("CreationDateTime"); + + b.HasIndex("DeletedDateTime"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("ModificationDateTime"); + + b.HasIndex("UniqueIdentity"); + + b.ToTable("Departmants"); + }); + + modelBuilder.Entity("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketAssignEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreationDateTime") + .HasColumnType("datetime2"); + + b.Property("DeletedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModificationDateTime") + .HasColumnType("datetime2"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("UniqueIdentity") + .HasColumnType("nvarchar(450)") + .UseCollation("SQL_Latin1_General_CP1_CS_AS"); + + b.HasKey("Id"); + + b.HasIndex("CreationDateTime"); + + b.HasIndex("DeletedDateTime"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("ModificationDateTime"); + + b.HasIndex("TicketId"); + + b.HasIndex("UniqueIdentity"); + + b.ToTable("TicketAssigns"); + }); + + modelBuilder.Entity("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketDepartmentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreationDateTime") + .HasColumnType("datetime2"); + + b.Property("DeletedDateTime") + .HasColumnType("datetime2"); + + b.Property("DepartmentId") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModificationDateTime") + .HasColumnType("datetime2"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("UniqueIdentity") + .HasColumnType("nvarchar(450)") + .UseCollation("SQL_Latin1_General_CP1_CS_AS"); + + b.HasKey("Id"); + + b.HasIndex("CreationDateTime"); + + b.HasIndex("DeletedDateTime"); + + b.HasIndex("DepartmentId"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("ModificationDateTime"); + + b.HasIndex("TicketId"); + + b.HasIndex("UniqueIdentity"); + + b.ToTable("TicketDepartments"); + }); + + modelBuilder.Entity("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketDiscussionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreationDateTime") + .HasColumnType("datetime2"); + + b.Property("DeletedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModificationDateTime") + .HasColumnType("datetime2"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("UniqueIdentity") + .HasColumnType("nvarchar(450)") + .UseCollation("SQL_Latin1_General_CP1_CS_AS"); + + b.HasKey("Id"); + + b.HasIndex("CreationDateTime"); + + b.HasIndex("DeletedDateTime"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("ModificationDateTime"); + + b.HasIndex("TicketId"); + + b.HasIndex("UniqueIdentity"); + + b.ToTable("TicketDiscussions"); + }); + + modelBuilder.Entity("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreationDateTime") + .HasColumnType("datetime2"); + + b.Property("DeletedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModificationDateTime") + .HasColumnType("datetime2"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("SensitivityStatus") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("UniqueIdentity") + .HasColumnType("nvarchar(450)") + .UseCollation("SQL_Latin1_General_CP1_CS_AS"); + + b.HasKey("Id"); + + b.HasIndex("CreationDateTime"); + + b.HasIndex("DeletedDateTime"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("ModificationDateTime"); + + b.HasIndex("UniqueIdentity"); + + b.ToTable("Tickets"); + }); + + modelBuilder.Entity("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketHistoryEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreationDateTime") + .HasColumnType("datetime2"); + + b.Property("DeletedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModificationDateTime") + .HasColumnType("datetime2"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("UniqueIdentity") + .HasColumnType("nvarchar(450)") + .UseCollation("SQL_Latin1_General_CP1_CS_AS"); + + b.HasKey("Id"); + + b.HasIndex("CreationDateTime"); + + b.HasIndex("DeletedDateTime"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("ModificationDateTime"); + + b.HasIndex("TicketId"); + + b.HasIndex("UniqueIdentity"); + + b.ToTable("TicketHistories"); + }); + + modelBuilder.Entity("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketSupportTimeHistoryEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreationDateTime") + .HasColumnType("datetime2"); + + b.Property("DeletedDateTime") + .HasColumnType("datetime2"); + + b.Property("EndDateTime") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModificationDateTime") + .HasColumnType("datetime2"); + + b.Property("StartDateTime") + .HasColumnType("datetime2"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("UniqueIdentity") + .HasColumnType("nvarchar(450)") + .UseCollation("SQL_Latin1_General_CP1_CS_AS"); + + b.HasKey("Id"); + + b.HasIndex("CreationDateTime"); + + b.HasIndex("DeletedDateTime"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("ModificationDateTime"); + + b.HasIndex("TicketId"); + + b.HasIndex("UniqueIdentity"); + + b.ToTable("TicketSupportTimeHistories"); + }); + + modelBuilder.Entity("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketAssignEntity", b => + { + b.HasOne("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketEntity", "Ticket") + .WithMany("TicketAssigns") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketDepartmentEntity", b => + { + b.HasOne("EasyMicroservices.SupportsMicroservice.Database.Entities.DepartmentEntity", "Department") + .WithMany("TicketDepartments") + .HasForeignKey("DepartmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketEntity", "Ticket") + .WithMany("TicketDepartments") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Department"); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketDiscussionEntity", b => + { + b.HasOne("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketEntity", "Ticket") + .WithMany("TicketDiscussions") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketHistoryEntity", b => + { + b.HasOne("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketEntity", "Ticket") + .WithMany("TicketHistories") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketSupportTimeHistoryEntity", b => + { + b.HasOne("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketEntity", "Ticket") + .WithMany("TicketSupportTimeHistories") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("EasyMicroservices.SupportsMicroservice.Database.Entities.DepartmentEntity", b => + { + b.Navigation("TicketDepartments"); + }); + + modelBuilder.Entity("EasyMicroservices.SupportsMicroservice.Database.Entities.TicketEntity", b => + { + b.Navigation("TicketAssigns"); + + b.Navigation("TicketDepartments"); + + b.Navigation("TicketDiscussions"); + + b.Navigation("TicketHistories"); + + b.Navigation("TicketSupportTimeHistories"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Migrations/20231130075023_Delete_Title.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Migrations/20231130075023_Delete_Title.cs new file mode 100644 index 0000000..bffe882 --- /dev/null +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Migrations/20231130075023_Delete_Title.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace EasyMicroservices.SupportsMicroservice.Migrations +{ + /// + public partial class Delete_Title : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Title", + table: "Departmants"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Title", + table: "Departmants", + type: "nvarchar(max)", + nullable: true); + } + } +} diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Migrations/SupportContextModelSnapshot.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Migrations/SupportContextModelSnapshot.cs index 0c5f351..6fdb47e 100644 --- a/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Migrations/SupportContextModelSnapshot.cs +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.Database/Migrations/SupportContextModelSnapshot.cs @@ -42,9 +42,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ModificationDateTime") .HasColumnType("datetime2"); - b.Property("Title") - .HasColumnType("nvarchar(max)"); - b.Property("UniqueIdentity") .HasColumnType("nvarchar(450)") .UseCollation("SQL_Latin1_General_CP1_CS_AS"); diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/DepartmentContract.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/DepartmentContract.cs index 506664b..0825725 100644 --- a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/DepartmentContract.cs +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/DepartmentContract.cs @@ -1,4 +1,5 @@ -using EasyMicroservices.Cores.Interfaces; +using EasyMicroservices.ContentsMicroservice.Clients.Attributes; +using EasyMicroservices.Cores.Interfaces; using System; using System.Collections.Generic; using System.Linq; @@ -10,6 +11,7 @@ namespace EasyMicroservices.SupportsMicroservice.Contracts.Common public class DepartmentContract : IUniqueIdentitySchema, ISoftDeleteSchema, IDateTimeSchema { public long Id { get; set; } + [ContentLanguage] public string Title { get; set; } public string UniqueIdentity { get; set; } public bool IsDeleted { get; set; } diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/DepartmentLanguageContract.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/DepartmentLanguageContract.cs new file mode 100644 index 0000000..419832a --- /dev/null +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/DepartmentLanguageContract.cs @@ -0,0 +1,21 @@ +using EasyMicroservices.ContentsMicroservice.Clients.Attributes; +using EasyMicroservices.Cores.Interfaces; +using EasyMicroservices.SupportsMicroservice.Contracts.Common; +using System; +using System.Collections.Generic; + +namespace EasyMicroservices.OrderingMicroservice.Contracts.Common +{ + public class DepartmentLanguageContract : IUniqueIdentitySchema, ISoftDeleteSchema, IDateTimeSchema + { + public long Id { get; set; } + + [ContentLanguage(nameof(DepartmentContract.Title))] + public List Titles { get; set; } + public string UniqueIdentity { get; set; } + public bool IsDeleted { get; set; } + public DateTime? DeletedDateTime { get; set; } + public DateTime CreationDateTime { get; set; } + public DateTime? ModificationDateTime { get; set; } + } +} \ No newline at end of file diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/LanguageDataContract.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/LanguageDataContract.cs new file mode 100644 index 0000000..4f8db4a --- /dev/null +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/LanguageDataContract.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EasyMicroservices.SupportsMicroservice.Contracts.Common +{ + public class LanguageDataContract + { + public string Language { get; set; } + public string Data { get; set; } + } +} diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/TicketHistoryContract.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/TicketHistoryContract.cs index 3a334ca..9d70c2b 100644 --- a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/TicketHistoryContract.cs +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/TicketHistoryContract.cs @@ -1,4 +1,5 @@ -using EasyMicroservices.Cores.Interfaces; +using EasyMicroservices.ContentsMicroservice.Clients.Attributes; +using EasyMicroservices.Cores.Interfaces; using System; using System.Collections.Generic; using System.Linq; @@ -11,6 +12,7 @@ public class TicketHistoryContract : IUniqueIdentitySchema, ISoftDeleteSchema, I { public long Id { get; set; } public long TicketId { get; set; } + [ContentLanguage] public string Content { get; set; } public string UniqueIdentity { get; set; } public bool IsDeleted { get; set; } diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/TicketHistoryLanguageContract.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/TicketHistoryLanguageContract.cs new file mode 100644 index 0000000..ee3be0a --- /dev/null +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Common/TicketHistoryLanguageContract.cs @@ -0,0 +1,21 @@ +using EasyMicroservices.ContentsMicroservice.Clients.Attributes; +using EasyMicroservices.Cores.Interfaces; +using EasyMicroservices.SupportsMicroservice.Contracts.Common; +using System; +using System.Collections.Generic; + +namespace EasyMicroservices.OrderingMicroservice.Contracts.Common +{ + public class TicketHistoryLanguageContract : IUniqueIdentitySchema, ISoftDeleteSchema, IDateTimeSchema + { + public long Id { get; set; } + + [ContentLanguage(nameof(TicketHistoryContract.Content))] + public List Contents { get; set; } + public string UniqueIdentity { get; set; } + public bool IsDeleted { get; set; } + public DateTime? DeletedDateTime { get; set; } + public DateTime CreationDateTime { get; set; } + public DateTime? ModificationDateTime { get; set; } + } +} \ No newline at end of file diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/CreateDepartmentRequestContract.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/CreateDepartmentRequestContract.cs index 7e80e2b..8d8913c 100644 --- a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/CreateDepartmentRequestContract.cs +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/CreateDepartmentRequestContract.cs @@ -1,4 +1,7 @@ -using System; +using Contents.GeneratedServices; +using EasyMicroservices.ContentsMicroservice.Clients.Attributes; +using EasyMicroservices.SupportsMicroservice.Contracts.Common; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,7 +11,8 @@ namespace EasyMicroservices.SupportsMicroservice.Contracts.Requests { public class CreateDepartmentRequestContract { - public string Title { get; set; } + [ContentLanguage(nameof(DepartmentContract.Title))] + public List Title { get; set; } public string UniqueIdentity { get; set; } } } diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/CreateTicketHistoryRequestContract.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/CreateTicketHistoryRequestContract.cs index b1578ec..a11d68b 100644 --- a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/CreateTicketHistoryRequestContract.cs +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/CreateTicketHistoryRequestContract.cs @@ -1,4 +1,6 @@ -using System; +using EasyMicroservices.ContentsMicroservice.Clients.Attributes; +using EasyMicroservices.SupportsMicroservice.Contracts.Common; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,7 +11,8 @@ namespace EasyMicroservices.SupportsMicroservice.Contracts.Requests public class CreateTicketHistoryRequestContract { public long TicketId { get; set; } - public string Content { get; set; } + [ContentLanguage(nameof(TicketHistoryContract.Content))] + public List Content { get; set; } public string UniqueIdentity { get; set; } } } diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/GetByLanguageRequestContract.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/GetByLanguageRequestContract.cs new file mode 100644 index 0000000..6bdaee1 --- /dev/null +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/GetByLanguageRequestContract.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EasyMicroservices.SupportsMicroservice.Contracts.Requests +{ + public class GetByLanguageRequestContract + { + public string Language { get; set; } + } +} diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/UpdateDepartmentRequestContract.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/UpdateDepartmentRequestContract.cs index 71ad127..a6ef86f 100644 --- a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/UpdateDepartmentRequestContract.cs +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/UpdateDepartmentRequestContract.cs @@ -6,10 +6,8 @@ namespace EasyMicroservices.SupportsMicroservice.Contracts.Requests { - public class UpdateDepartmentRequestContract + public class UpdateDepartmentRequestContract : CreateDepartmentRequestContract { public long Id { get; set; } - public string Title { get; set; } - public string UniqueIdentity { get; set; } } } diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/UpdateTicketHistoryRequestContract.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/UpdateTicketHistoryRequestContract.cs index 7e894b9..b988c84 100644 --- a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/UpdateTicketHistoryRequestContract.cs +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/Contracts/Requests/UpdateTicketHistoryRequestContract.cs @@ -6,11 +6,8 @@ namespace EasyMicroservices.SupportsMicroservice.Contracts.Requests { - public class UpdateTicketHistoryRequestContract + public class UpdateTicketHistoryRequestContract : CreateTicketHistoryRequestContract { public long Id { get; set; } - public long TicketId { get; set; } - public string Content { get; set; } - public string UniqueIdentity { get; set; } } } diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/EasyMicroservices.SupportsMicroservice.Domain.csproj b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/EasyMicroservices.SupportsMicroservice.Domain.csproj index 372f80b..8196c39 100644 --- a/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/EasyMicroservices.SupportsMicroservice.Domain.csproj +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.Domain/EasyMicroservices.SupportsMicroservice.Domain.csproj @@ -11,6 +11,7 @@ + diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/Controllers/DepartmentController.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/Controllers/DepartmentController.cs index 0d492a7..955a246 100644 --- a/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/Controllers/DepartmentController.cs +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/Controllers/DepartmentController.cs @@ -1,21 +1,82 @@ -using EasyMicroservices.Cores.AspCoreApi; -using EasyMicroservices.Cores.Database.Interfaces; +using EasyMicroservices.ContentsMicroservice.Clients.Helpers; +using EasyMicroservices.Cores.AspCoreApi; +using EasyMicroservices.Cores.AspEntityFrameworkCoreApi.Interfaces; +using EasyMicroservices.Cores.Contracts.Requests; +using EasyMicroservices.OrderingMicroservice.Contracts.Common; +using EasyMicroservices.ServiceContracts; using EasyMicroservices.SupportsMicroservice.Contracts.Common; using EasyMicroservices.SupportsMicroservice.Contracts.Requests; using EasyMicroservices.SupportsMicroservice.Database.Entities; -using EasyMicroservices.Cores.AspEntityFrameworkCoreApi.Interfaces; - - +using Microsoft.AspNetCore.Mvc; namespace EasyMicroservices.SupportsMicroservice.WebApi.Controllers { public class DepartmentController : SimpleQueryServiceController { - public IUnitOfWork _uow; + private readonly IConfiguration _config; + readonly IUnitOfWork _uow; + private readonly ContentLanguageHelper _contentHelper; - public DepartmentController(IUnitOfWork uow) : base(uow) + + + public DepartmentController(IUnitOfWork uow, IConfiguration config) : base(uow) { _uow = uow; + _config = config; + _contentHelper = new(new Contents.GeneratedServices.ContentClient(_config.GetValue("RootAddresses:Content"), new HttpClient())); + } + public override async Task> Add(CreateDepartmentRequestContract request, CancellationToken cancellationToken = default) + { + var result = await base.Add(request, cancellationToken); + if (result) + { + var addedItem = await GetById(new Cores.Contracts.Requests.GetIdRequestContract { Id = result.Result }); + request.UniqueIdentity = addedItem.Result.UniqueIdentity; + + var addContent = await _contentHelper.AddToContentLanguage(request); + if (!addContent.IsSuccess) + return addContent.ToContract(); + } + return result; + } + public override async Task> Update(UpdateDepartmentRequestContract request, CancellationToken cancellationToken = default) + { + var addedItem = await GetById(new Cores.Contracts.Requests.GetIdRequestContract { Id = request.Id }); + if (addedItem) + { + request.UniqueIdentity = addedItem.Result.UniqueIdentity; + var result = await base.Update(request, cancellationToken); + if (result) + { + var updateToContent = await _contentHelper.UpdateToContentLanguage(request); + if (!updateToContent.IsSuccess) + return updateToContent.ToContract(); + } + return result; + } + return addedItem.ToContract(); + } + [HttpPost] + public async Task> GetByIdAllLanguage(GetIdRequestContract request) + { + var result = await base.GetById(request.Id); + if (result) + { + var mapped = _uow.GetMapper().Map(result.Result); + await _contentHelper.ResolveContentAllLanguage(mapped); + return mapped; + } + return result.ToContract(); + } + [HttpPost] + public async Task> GetAllByLanguage(Contracts.Requests.GetByLanguageRequestContract getByLanguage, CancellationToken cancellationToken = default) + { + var result = await base.GetAll(cancellationToken); + if (result) + { + await _contentHelper.ResolveContentLanguage(result.Result, getByLanguage.Language); + } + return result; } } } diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/Controllers/TicketHistoryController.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/Controllers/TicketHistoryController.cs index 615efc5..f4cdf3c 100644 --- a/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/Controllers/TicketHistoryController.cs +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/Controllers/TicketHistoryController.cs @@ -1,21 +1,80 @@ -using EasyMicroservices.Cores.AspCoreApi; +using EasyMicroservices.ContentsMicroservice.Clients.Helpers; +using EasyMicroservices.Cores.AspCoreApi; using EasyMicroservices.Cores.AspEntityFrameworkCoreApi.Interfaces; using EasyMicroservices.Cores.Contracts.Requests; using EasyMicroservices.Cores.Database.Interfaces; +using EasyMicroservices.OrderingMicroservice.Contracts.Common; using EasyMicroservices.ServiceContracts; using EasyMicroservices.SupportsMicroservice.Contracts.Common; using EasyMicroservices.SupportsMicroservice.Contracts.Requests; using EasyMicroservices.SupportsMicroservice.Database.Entities; +using Microsoft.AspNetCore.Mvc; namespace EasyMicroservices.SupportsMicroservice.WebApi.Controllers { public class TicketHistoryController : SimpleQueryServiceController { - public IUnitOfWork _uow; - - public TicketHistoryController(IUnitOfWork uow) : base(uow) + private readonly IConfiguration _config; + readonly IUnitOfWork _uow; + private readonly ContentLanguageHelper _contentHelper; + public TicketHistoryController(IUnitOfWork uow ,IConfiguration config) : base(uow) { _uow = uow; + _config = config; + _contentHelper = new(new Contents.GeneratedServices.ContentClient(_config.GetValue("RootAddresses:Content"), new HttpClient())); + } + public override async Task> Add(CreateTicketHistoryRequestContract request, CancellationToken cancellationToken = default) + { + var result = await base.Add(request, cancellationToken); + if (result) + { + var addedItem = await GetById(new Cores.Contracts.Requests.GetIdRequestContract { Id = result.Result }); + request.UniqueIdentity = addedItem.Result.UniqueIdentity; + + var addContent = await _contentHelper.AddToContentLanguage(request); + if (!addContent.IsSuccess) + return addContent.ToContract(); + } + return result; + } + public override async Task> Update(UpdateTicketHistoryRequestContract request, CancellationToken cancellationToken = default) + { + var addedItem = await GetById(new Cores.Contracts.Requests.GetIdRequestContract { Id = request.Id }); + if (addedItem) + { + request.UniqueIdentity = addedItem.Result.UniqueIdentity; + var result = await base.Update(request, cancellationToken); + if (result) + { + var updateToContent = await _contentHelper.UpdateToContentLanguage(request); + if (!updateToContent.IsSuccess) + return updateToContent.ToContract(); + } + return result; + } + return addedItem.ToContract(); + } + [HttpPost] + public async Task> GetByIdAllLanguage(GetIdRequestContract request) + { + var result = await base.GetById(request.Id); + if (result) + { + var mapped = _uow.GetMapper().Map(result.Result); + await _contentHelper.ResolveContentAllLanguage(mapped); + return mapped; + } + return result.ToContract(); + } + [HttpPost] + public async Task> GetAllByLanguage(Contracts.Requests.GetByLanguageRequestContract getByLanguage, CancellationToken cancellationToken = default) + { + var result = await base.GetAll(cancellationToken); + if (result) + { + await _contentHelper.ResolveContentLanguage(result.Result, getByLanguage.Language); + } + return result; } } } diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/Program.cs b/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/Program.cs index 4074659..1c61083 100644 --- a/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/Program.cs +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/Program.cs @@ -18,7 +18,7 @@ public static async Task Main(string[] args) } static WebApplicationBuilder CreateBuilder(string[] args) - { + { var app = StartUpExtensions.Create(args); app.Services.Builder(); app.Services.AddTransient((serviceProvider) => new UnitOfWork(serviceProvider)); diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/appsettings.Development.json b/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/appsettings.Development.json index 44417be..6644f5d 100644 --- a/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/appsettings.Development.json +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/appsettings.Development.json @@ -10,7 +10,8 @@ "local": "Server=.;Database=Supports;Integrated Security=True;Trusted_Connection=True;TrustServerCertificate=True" }, "RootAddresses": { - "WhiteLabel": "http://localhost:1041" + "WhiteLabel": "http://localhost:1041", + "Content": "http://localhost:2003" }, "Urls": "http://*:2001" } diff --git a/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/appsettings.json b/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/appsettings.json index 44417be..6644f5d 100644 --- a/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/appsettings.json +++ b/src/CSharp/EasyMicroservices.SupportsMicroservice.WebApi/appsettings.json @@ -10,7 +10,8 @@ "local": "Server=.;Database=Supports;Integrated Security=True;Trusted_Connection=True;TrustServerCertificate=True" }, "RootAddresses": { - "WhiteLabel": "http://localhost:1041" + "WhiteLabel": "http://localhost:1041", + "Content": "http://localhost:2003" }, "Urls": "http://*:2001" }