From deb086e6a8f9cd00a7f41a13f4df73bed4a61921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 20 Sep 2019 14:52:35 +0300 Subject: [PATCH] Add constrators getting id to the base entity classes. --- .../Entities/Auditing/AuditedAggregateRoot.cs | 11 ++++++++ .../Auditing/AuditedAggregateRootWithUser.cs | 11 ++++++++ .../Domain/Entities/Auditing/AuditedEntity.cs | 11 ++++++++ .../Auditing/AuditedEntityWithUser.cs | 11 ++++++++ .../Auditing/CreationAuditedAggregateRoot.cs | 11 ++++++++ .../CreationAuditedAggregateRootWithUser.cs | 11 ++++++++ .../Auditing/CreationAuditedEntity.cs | 11 ++++++++ .../Auditing/CreationAuditedEntityWithUser.cs | 11 ++++++++ .../Auditing/FullAuditedAggregateRoot.cs | 11 ++++++++ .../FullAuditedAggregateRootWithUser.cs | 11 ++++++++ .../Entities/Auditing/FullAuditedEntity.cs | 11 ++++++++ .../Auditing/FullAuditedEntityWithUser.cs | 11 ++++++++ .../SecondContext/BookInSecondDbContext.cs | 11 ++++++++ .../SecondContextTestDataBuilder.cs | 11 ++++---- .../Transactions/Transaction_Tests.cs | 2 +- .../EventBus/Local/GenericInheritanceTest.cs | 28 +++++++++++++++---- .../Volo/Abp/TestApp/Domain/Person.cs | 2 +- .../Volo/Abp/TestApp/Domain/Phone.cs | 2 +- .../Controllers/HomeController.cs | 4 ++- .../Controllers/HomeController.cs | 4 ++- 20 files changed, 181 insertions(+), 15 deletions(-) diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRoot.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRoot.cs index 8f566f1b6b..bc4830bc03 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRoot.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRoot.cs @@ -28,5 +28,16 @@ namespace Volo.Abp.Domain.Entities.Auditing /// public virtual Guid? LastModifierId { get; set; } + + protected AuditedAggregateRoot() + { + + } + + protected AuditedAggregateRoot(TKey id) + : base(id) + { + + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRootWithUser.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRootWithUser.cs index 107fb35b68..ec490fbb50 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRootWithUser.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRootWithUser.cs @@ -32,5 +32,16 @@ namespace Volo.Abp.Domain.Entities.Auditing /// public virtual TUser LastModifier { get; set; } + + protected AuditedAggregateRootWithUser() + { + + } + + protected AuditedAggregateRootWithUser(TKey id) + : base(id) + { + + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntity.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntity.cs index 2ccc1aa1e2..0423551509 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntity.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntity.cs @@ -28,5 +28,16 @@ namespace Volo.Abp.Domain.Entities.Auditing /// public virtual Guid? LastModifierId { get; set; } + + protected AuditedEntity() + { + + } + + protected AuditedEntity(TKey id) + : base(id) + { + + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntityWithUser.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntityWithUser.cs index 76002b2114..fd6aeb9dd9 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntityWithUser.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntityWithUser.cs @@ -32,5 +32,16 @@ namespace Volo.Abp.Domain.Entities.Auditing /// public virtual TUser LastModifier { get; set; } + + protected AuditedEntityWithUser() + { + + } + + protected AuditedEntityWithUser(TKey id) + : base(id) + { + + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRoot.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRoot.cs index 29c01bd466..084c907606 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRoot.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRoot.cs @@ -28,5 +28,16 @@ namespace Volo.Abp.Domain.Entities.Auditing /// public virtual Guid? CreatorId { get; set; } + + protected CreationAuditedAggregateRoot() + { + + } + + protected CreationAuditedAggregateRoot(TKey id) + : base(id) + { + + } } } diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRootWithUser.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRootWithUser.cs index 1084360749..7d491d7be1 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRootWithUser.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRootWithUser.cs @@ -24,5 +24,16 @@ namespace Volo.Abp.Domain.Entities.Auditing { /// public virtual TUser Creator { get; set; } + + protected CreationAuditedAggregateRootWithUser() + { + + } + + protected CreationAuditedAggregateRootWithUser(TKey id) + : base(id) + { + + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntity.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntity.cs index 1ab527dc2a..41802c78b7 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntity.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntity.cs @@ -28,5 +28,16 @@ namespace Volo.Abp.Domain.Entities.Auditing /// public virtual Guid? CreatorId { get; set; } + + protected CreationAuditedEntity() + { + + } + + protected CreationAuditedEntity(TKey id) + : base(id) + { + + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntityWithUser.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntityWithUser.cs index 0989dfeac4..45d844efa7 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntityWithUser.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntityWithUser.cs @@ -24,5 +24,16 @@ namespace Volo.Abp.Domain.Entities.Auditing { /// public virtual TUser Creator { get; set; } + + protected CreationAuditedEntityWithUser() + { + + } + + protected CreationAuditedEntityWithUser(TKey id) + : base(id) + { + + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRoot.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRoot.cs index 397a425629..9231efd3ab 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRoot.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRoot.cs @@ -34,5 +34,16 @@ namespace Volo.Abp.Domain.Entities.Auditing /// public virtual DateTime? DeletionTime { get; set; } + + protected FullAuditedAggregateRoot() + { + + } + + protected FullAuditedAggregateRoot(TKey id) + : base(id) + { + + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRootWithUser.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRootWithUser.cs index d379a78240..cb0be46421 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRootWithUser.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRootWithUser.cs @@ -38,5 +38,16 @@ namespace Volo.Abp.Domain.Entities.Auditing /// public TUser LastModifier { get; set; } + + protected FullAuditedAggregateRootWithUser() + { + + } + + protected FullAuditedAggregateRootWithUser(TKey id) + : base(id) + { + + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntity.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntity.cs index 20b07b85b5..ada5cc9eed 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntity.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntity.cs @@ -34,5 +34,16 @@ namespace Volo.Abp.Domain.Entities.Auditing /// public virtual DateTime? DeletionTime { get; set; } + + protected FullAuditedEntity() + { + + } + + protected FullAuditedEntity(TKey id) + : base(id) + { + + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntityWithUser.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntityWithUser.cs index 9aba520480..12458ebf99 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntityWithUser.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntityWithUser.cs @@ -38,5 +38,16 @@ namespace Volo.Abp.Domain.Entities.Auditing /// public TUser LastModifier { get; set; } + + protected FullAuditedEntityWithUser() + { + + } + + protected FullAuditedEntityWithUser(TKey id) + : base(id) + { + + } } } \ No newline at end of file diff --git a/framework/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo/Abp/EntityFrameworkCore/TestApp/SecondContext/BookInSecondDbContext.cs b/framework/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo/Abp/EntityFrameworkCore/TestApp/SecondContext/BookInSecondDbContext.cs index 0e22533c11..59c568ed9d 100644 --- a/framework/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo/Abp/EntityFrameworkCore/TestApp/SecondContext/BookInSecondDbContext.cs +++ b/framework/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo/Abp/EntityFrameworkCore/TestApp/SecondContext/BookInSecondDbContext.cs @@ -6,5 +6,16 @@ namespace Volo.Abp.EntityFrameworkCore.TestApp.SecondContext public class BookInSecondDbContext : AggregateRoot { public string Name { get; set; } + + public BookInSecondDbContext() + { + + } + + public BookInSecondDbContext(Guid id, string name) + : base(id) + { + Name = name; + } } } \ No newline at end of file diff --git a/framework/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo/Abp/EntityFrameworkCore/TestApp/SecondContext/SecondContextTestDataBuilder.cs b/framework/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo/Abp/EntityFrameworkCore/TestApp/SecondContext/SecondContextTestDataBuilder.cs index 59ddc2acdf..0b89576f34 100644 --- a/framework/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo/Abp/EntityFrameworkCore/TestApp/SecondContext/SecondContextTestDataBuilder.cs +++ b/framework/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo/Abp/EntityFrameworkCore/TestApp/SecondContext/SecondContextTestDataBuilder.cs @@ -18,11 +18,12 @@ namespace Volo.Abp.EntityFrameworkCore.TestApp.SecondContext public void Build() { - _bookRepository.Insert(new BookInSecondDbContext - { - Id = _guidGenerator.Create(), - Name = "TestBook1" - }); + _bookRepository.Insert( + new BookInSecondDbContext( + _guidGenerator.Create(), + "TestBook1" + ) + ); } } } \ No newline at end of file diff --git a/framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/Transactions/Transaction_Tests.cs b/framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/Transactions/Transaction_Tests.cs index 030b236637..613c42894c 100644 --- a/framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/Transactions/Transaction_Tests.cs +++ b/framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/Transactions/Transaction_Tests.cs @@ -80,7 +80,7 @@ namespace Volo.Abp.EntityFrameworkCore.Transactions _unitOfWorkManager.Current.ShouldNotBeNull(); await _personRepository.InsertAsync(new Person(personId, "Adam", 42)); - await _bookRepository.InsertAsync(new BookInSecondDbContext { Id = bookId, Name = bookId.ToString() }); + await _bookRepository.InsertAsync(new BookInSecondDbContext(bookId, bookId.ToString())); await _unitOfWorkManager.Current.SaveChangesAsync(); diff --git a/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Local/GenericInheritanceTest.cs b/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Local/GenericInheritanceTest.cs index d770a81325..eeec26b166 100644 --- a/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Local/GenericInheritanceTest.cs +++ b/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Local/GenericInheritanceTest.cs @@ -21,7 +21,7 @@ namespace Volo.Abp.EventBus.Local return Task.CompletedTask; }); - await LocalEventBus.PublishAsync(new EntityUpdatedEventData(new Person { Id = 42 })); + await LocalEventBus.PublishAsync(new EntityUpdatedEventData(new Person(42))); triggeredEvent.ShouldBe(true); } @@ -39,19 +39,37 @@ namespace Volo.Abp.EventBus.Local return Task.CompletedTask; }); - await LocalEventBus.PublishAsync(new EntityChangedEventData(new Student { Id = 42 })); + await LocalEventBus.PublishAsync(new EntityChangedEventData(new Student(42))); triggeredEvent.ShouldBe(true); } - + public class Person : Entity { - + public Person() + { + + } + + public Person(int id) + : base(id) + { + + } } public class Student : Person { - + public Student() + { + + } + + public Student(int id) + : base(id) + { + + } } } } \ No newline at end of file diff --git a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Person.cs b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Person.cs index 16ac62589e..3bbec118a2 100644 --- a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Person.cs +++ b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Person.cs @@ -23,8 +23,8 @@ namespace Volo.Abp.TestApp.Domain } public Person(Guid id, string name, int age, Guid? tenantId = null, Guid? cityId = null) + : base(id) { - Id = id; Name = name; Age = age; TenantId = tenantId; diff --git a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Phone.cs b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Phone.cs index e53f2bc2e3..20292e3de8 100644 --- a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Phone.cs +++ b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Phone.cs @@ -49,8 +49,8 @@ namespace Volo.Abp.TestApp.Domain } public Order(Guid id, string referenceNo) + : base(id) { - Id = id; ReferenceNo = referenceNo; OrderLines = new List(); } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs index 66ab9f58d0..71c6127f9e 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs @@ -7,7 +7,9 @@ namespace MyCompanyName.MyProjectName.Controllers { public ActionResult Index() { - return Redirect("/swagger"); + //TODO: Enabled once Swagger supports ASP.NET Core 3.x + //return Redirect("/swagger"); + return Content("OK: MyCompanyName.MyProjectName.HttpApi.HostWithIds is running..."); } } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Controllers/HomeController.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Controllers/HomeController.cs index 66ab9f58d0..71c6127f9e 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Controllers/HomeController.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Controllers/HomeController.cs @@ -7,7 +7,9 @@ namespace MyCompanyName.MyProjectName.Controllers { public ActionResult Index() { - return Redirect("/swagger"); + //TODO: Enabled once Swagger supports ASP.NET Core 3.x + //return Redirect("/swagger"); + return Content("OK: MyCompanyName.MyProjectName.HttpApi.HostWithIds is running..."); } } }