From 42721a7a8ac97e15dfd29de1624d44979d65950b Mon Sep 17 00:00:00 2001 From: vivet Date: Wed, 23 Oct 2024 19:43:10 +0200 Subject: [PATCH] Updated with UxException --- Api/Nano.Template.Api/appsettings.json | 4 ++-- Service/Nano.Template.Service.Models/Data/Sample.cs | 2 ++ .../Nano.Template.Service/Controllers/UsersController.cs | 2 +- .../Nano.Template.Service/Data/Mappings/SampleMapping.cs | 3 ++- ...itial.Designer.cs => 20241023164647_Initial.Designer.cs} | 6 ++++-- ...{20240830051353_Initial.cs => 20241023164647_Initial.cs} | 5 +++-- .../Migrations/ServiceDbContextModelSnapshot.cs | 4 +++- 7 files changed, 17 insertions(+), 9 deletions(-) rename Service/Nano.Template.Service/Migrations/{20240830051353_Initial.Designer.cs => 20241023164647_Initial.Designer.cs} (99%) rename Service/Nano.Template.Service/Migrations/{20240830051353_Initial.cs => 20241023164647_Initial.cs} (99%) diff --git a/Api/Nano.Template.Api/appsettings.json b/Api/Nano.Template.Api/appsettings.json index aba8c55..fa48aca 100644 --- a/Api/Nano.Template.Api/appsettings.json +++ b/Api/Nano.Template.Api/appsettings.json @@ -423,8 +423,8 @@ "Logging": { "LogLevel": "Debug" }, - "WebApi": { - "Host": "nano-template-web", + "ServiceApi": { + "Host": "nano-template-service", "Root": "api", "Port": 8080, "UseSsl": false, diff --git a/Service/Nano.Template.Service.Models/Data/Sample.cs b/Service/Nano.Template.Service.Models/Data/Sample.cs index e7a5366..232091c 100644 --- a/Service/Nano.Template.Service.Models/Data/Sample.cs +++ b/Service/Nano.Template.Service.Models/Data/Sample.cs @@ -1,12 +1,14 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Nano.Models; +using Nano.Models.Attributes; namespace Nano.Template.Service.Models.Data; /// /// Sample. /// +[UxException("UX Sample Exception", [nameof(Name)])] public class Sample : DefaultEntity { /// diff --git a/Service/Nano.Template.Service/Controllers/UsersController.cs b/Service/Nano.Template.Service/Controllers/UsersController.cs index b330ede..dddb203 100644 --- a/Service/Nano.Template.Service/Controllers/UsersController.cs +++ b/Service/Nano.Template.Service/Controllers/UsersController.cs @@ -9,7 +9,7 @@ namespace Nano.Template.Service.Controllers; /// -public class UsersController : DefaultIdentityController +public class UsersController : BaseDefaultIdentityController { /// public UsersController(ILogger logger, IRepository repository, IEventing eventing, DefaultIdentityManager identityManager) diff --git a/Service/Nano.Template.Service/Data/Mappings/SampleMapping.cs b/Service/Nano.Template.Service/Data/Mappings/SampleMapping.cs index d2a2734..8f75f3d 100644 --- a/Service/Nano.Template.Service/Data/Mappings/SampleMapping.cs +++ b/Service/Nano.Template.Service/Data/Mappings/SampleMapping.cs @@ -27,7 +27,8 @@ public override void Map(EntityTypeBuilder builder) .IsRequired(); builder - .HasIndex(x => x.Name); + .HasIndex(x => x.Name) + .IsUnique(); builder .Ignore(x => x.HasName); diff --git a/Service/Nano.Template.Service/Migrations/20240830051353_Initial.Designer.cs b/Service/Nano.Template.Service/Migrations/20241023164647_Initial.Designer.cs similarity index 99% rename from Service/Nano.Template.Service/Migrations/20240830051353_Initial.Designer.cs rename to Service/Nano.Template.Service/Migrations/20241023164647_Initial.Designer.cs index f1c071e..35c8306 100644 --- a/Service/Nano.Template.Service/Migrations/20240830051353_Initial.Designer.cs +++ b/Service/Nano.Template.Service/Migrations/20241023164647_Initial.Designer.cs @@ -12,7 +12,7 @@ namespace Nano.Template.Service.Migrations { [DbContext(typeof(ServiceDbContext))] - [Migration("20240830051353_Initial")] + [Migration("20241023164647_Initial")] partial class Initial { /// @@ -385,7 +385,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasIndex("IsDeleted"); - b.HasIndex("Name"); + b.HasIndex("Name", "IsDeleted") + .IsUnique() + .HasDatabaseName("UX_Sample_Name_IsDeleted"); b.ToTable("Sample"); diff --git a/Service/Nano.Template.Service/Migrations/20240830051353_Initial.cs b/Service/Nano.Template.Service/Migrations/20241023164647_Initial.cs similarity index 99% rename from Service/Nano.Template.Service/Migrations/20240830051353_Initial.cs rename to Service/Nano.Template.Service/Migrations/20241023164647_Initial.cs index 721d711..eb44631 100644 --- a/Service/Nano.Template.Service/Migrations/20240830051353_Initial.cs +++ b/Service/Nano.Template.Service/Migrations/20241023164647_Initial.cs @@ -419,9 +419,10 @@ protected override void Up(MigrationBuilder migrationBuilder) column: "IsDeleted"); migrationBuilder.CreateIndex( - name: "IX_Sample_Name", + name: "UX_Sample_Name_IsDeleted", table: "Sample", - column: "Name"); + columns: new[] { "Name", "IsDeleted" }, + unique: true); migrationBuilder.CreateIndex( name: "IX_User_CreatedAt", diff --git a/Service/Nano.Template.Service/Migrations/ServiceDbContextModelSnapshot.cs b/Service/Nano.Template.Service/Migrations/ServiceDbContextModelSnapshot.cs index 2368627..6c3f05d 100644 --- a/Service/Nano.Template.Service/Migrations/ServiceDbContextModelSnapshot.cs +++ b/Service/Nano.Template.Service/Migrations/ServiceDbContextModelSnapshot.cs @@ -382,7 +382,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("IsDeleted"); - b.HasIndex("Name"); + b.HasIndex("Name", "IsDeleted") + .IsUnique() + .HasDatabaseName("UX_Sample_Name_IsDeleted"); b.ToTable("Sample");