Browse Source

Add constrators getting id to the base entity classes.

pull/1810/head
Halil İbrahim Kalkan 6 years ago
parent
commit
deb086e6a8
  1. 11
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRoot.cs
  2. 11
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRootWithUser.cs
  3. 11
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntity.cs
  4. 11
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntityWithUser.cs
  5. 11
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRoot.cs
  6. 11
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRootWithUser.cs
  7. 11
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntity.cs
  8. 11
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntityWithUser.cs
  9. 11
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRoot.cs
  10. 11
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRootWithUser.cs
  11. 11
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntity.cs
  12. 11
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntityWithUser.cs
  13. 11
      framework/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo/Abp/EntityFrameworkCore/TestApp/SecondContext/BookInSecondDbContext.cs
  14. 11
      framework/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo/Abp/EntityFrameworkCore/TestApp/SecondContext/SecondContextTestDataBuilder.cs
  15. 2
      framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/Transactions/Transaction_Tests.cs
  16. 28
      framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Local/GenericInheritanceTest.cs
  17. 2
      framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Person.cs
  18. 2
      framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Phone.cs
  19. 4
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs
  20. 4
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Controllers/HomeController.cs

11
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRoot.cs

@ -28,5 +28,16 @@ namespace Volo.Abp.Domain.Entities.Auditing
/// <inheritdoc />
public virtual Guid? LastModifierId { get; set; }
protected AuditedAggregateRoot()
{
}
protected AuditedAggregateRoot(TKey id)
: base(id)
{
}
}
}

11
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRootWithUser.cs

@ -32,5 +32,16 @@ namespace Volo.Abp.Domain.Entities.Auditing
/// <inheritdoc />
public virtual TUser LastModifier { get; set; }
protected AuditedAggregateRootWithUser()
{
}
protected AuditedAggregateRootWithUser(TKey id)
: base(id)
{
}
}
}

11
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntity.cs

@ -28,5 +28,16 @@ namespace Volo.Abp.Domain.Entities.Auditing
/// <inheritdoc />
public virtual Guid? LastModifierId { get; set; }
protected AuditedEntity()
{
}
protected AuditedEntity(TKey id)
: base(id)
{
}
}
}

11
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntityWithUser.cs

@ -32,5 +32,16 @@ namespace Volo.Abp.Domain.Entities.Auditing
/// <inheritdoc />
public virtual TUser LastModifier { get; set; }
protected AuditedEntityWithUser()
{
}
protected AuditedEntityWithUser(TKey id)
: base(id)
{
}
}
}

11
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRoot.cs

@ -28,5 +28,16 @@ namespace Volo.Abp.Domain.Entities.Auditing
/// <inheritdoc />
public virtual Guid? CreatorId { get; set; }
protected CreationAuditedAggregateRoot()
{
}
protected CreationAuditedAggregateRoot(TKey id)
: base(id)
{
}
}
}

11
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRootWithUser.cs

@ -24,5 +24,16 @@ namespace Volo.Abp.Domain.Entities.Auditing
{
/// <inheritdoc />
public virtual TUser Creator { get; set; }
protected CreationAuditedAggregateRootWithUser()
{
}
protected CreationAuditedAggregateRootWithUser(TKey id)
: base(id)
{
}
}
}

11
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntity.cs

@ -28,5 +28,16 @@ namespace Volo.Abp.Domain.Entities.Auditing
/// <inheritdoc />
public virtual Guid? CreatorId { get; set; }
protected CreationAuditedEntity()
{
}
protected CreationAuditedEntity(TKey id)
: base(id)
{
}
}
}

11
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntityWithUser.cs

@ -24,5 +24,16 @@ namespace Volo.Abp.Domain.Entities.Auditing
{
/// <inheritdoc />
public virtual TUser Creator { get; set; }
protected CreationAuditedEntityWithUser()
{
}
protected CreationAuditedEntityWithUser(TKey id)
: base(id)
{
}
}
}

11
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRoot.cs

@ -34,5 +34,16 @@ namespace Volo.Abp.Domain.Entities.Auditing
/// <inheritdoc />
public virtual DateTime? DeletionTime { get; set; }
protected FullAuditedAggregateRoot()
{
}
protected FullAuditedAggregateRoot(TKey id)
: base(id)
{
}
}
}

11
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRootWithUser.cs

@ -38,5 +38,16 @@ namespace Volo.Abp.Domain.Entities.Auditing
/// <inheritdoc />
public TUser LastModifier { get; set; }
protected FullAuditedAggregateRootWithUser()
{
}
protected FullAuditedAggregateRootWithUser(TKey id)
: base(id)
{
}
}
}

11
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntity.cs

@ -34,5 +34,16 @@ namespace Volo.Abp.Domain.Entities.Auditing
/// <inheritdoc />
public virtual DateTime? DeletionTime { get; set; }
protected FullAuditedEntity()
{
}
protected FullAuditedEntity(TKey id)
: base(id)
{
}
}
}

11
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntityWithUser.cs

@ -38,5 +38,16 @@ namespace Volo.Abp.Domain.Entities.Auditing
/// <inheritdoc />
public TUser LastModifier { get; set; }
protected FullAuditedEntityWithUser()
{
}
protected FullAuditedEntityWithUser(TKey id)
: base(id)
{
}
}
}

11
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<Guid>
{
public string Name { get; set; }
public BookInSecondDbContext()
{
}
public BookInSecondDbContext(Guid id, string name)
: base(id)
{
Name = name;
}
}
}

11
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"
)
);
}
}
}

2
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();

28
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<Person>(new Person { Id = 42 }));
await LocalEventBus.PublishAsync(new EntityUpdatedEventData<Person>(new Person(42)));
triggeredEvent.ShouldBe(true);
}
@ -39,19 +39,37 @@ namespace Volo.Abp.EventBus.Local
return Task.CompletedTask;
});
await LocalEventBus.PublishAsync(new EntityChangedEventData<Student>(new Student { Id = 42 }));
await LocalEventBus.PublishAsync(new EntityChangedEventData<Student>(new Student(42)));
triggeredEvent.ShouldBe(true);
}
public class Person : Entity<int>
{
public Person()
{
}
public Person(int id)
: base(id)
{
}
}
public class Student : Person
{
public Student()
{
}
public Student(int id)
: base(id)
{
}
}
}
}

2
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;

2
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<OrderLine>();
}

4
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...");
}
}
}

4
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...");
}
}
}

Loading…
Cancel
Save