diff --git a/src/Volo.Abp.Ddd/Volo/Abp/Application/Dtos/EntityDto.cs b/src/Volo.Abp.Ddd/Volo/Abp/Application/Dtos/EntityDto.cs index 87f1457e86..aaf4e1da9a 100644 --- a/src/Volo.Abp.Ddd/Volo/Abp/Application/Dtos/EntityDto.cs +++ b/src/Volo.Abp.Ddd/Volo/Abp/Application/Dtos/EntityDto.cs @@ -1,33 +1,14 @@ -using System; - namespace Volo.Abp.Application.Dtos { - public class EntityDto : EntityDto, IEntityDto + public class EntityDto : IEntityDto //TODO: Consider to delete this class { - /// - /// Creates a new object. - /// - public EntityDto() - { - - } - - /// - /// Creates a new object. - /// - /// Id of the entity - public EntityDto(Guid id) - : base(id) + public override string ToString() { - + return $"[DTO: {GetType().Name}]"; } } - /// - /// Implements common properties for entity based DTOs. - /// - /// Type of the primary key - public class EntityDto : IEntityDto + public class EntityDto : EntityDto, IEntityDto { /// /// Id of the entity. @@ -53,7 +34,7 @@ namespace Volo.Abp.Application.Dtos public override string ToString() { - return $"[{GetType().Name}] Id = {Id}"; + return $"[DTO: {GetType().Name}] Id = {Id}"; } } } \ No newline at end of file diff --git a/src/Volo.Abp.Ddd/Volo/Abp/Application/Dtos/IEntityDto.cs b/src/Volo.Abp.Ddd/Volo/Abp/Application/Dtos/IEntityDto.cs index 390e2fb743..00e0f98cdb 100644 --- a/src/Volo.Abp.Ddd/Volo/Abp/Application/Dtos/IEntityDto.cs +++ b/src/Volo.Abp.Ddd/Volo/Abp/Application/Dtos/IEntityDto.cs @@ -1,24 +1,12 @@ -using System; - -namespace Volo.Abp.Application.Dtos +namespace Volo.Abp.Application.Dtos { - /// - /// A shortcut of for default primary key type (). - /// - public interface IEntityDto : IEntityDto + public interface IEntityDto { } - /// - /// Defines common properties for entity based DTOs. - /// - /// - public interface IEntityDto + public interface IEntityDto : IEntityDto { - /// - /// Id of the entity. - /// TPrimaryKey Id { get; set; } } } \ No newline at end of file diff --git a/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/AsyncCrudAppService.cs b/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/AsyncCrudAppService.cs index 0ed329c655..2e631d2f4c 100644 --- a/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/AsyncCrudAppService.cs +++ b/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/AsyncCrudAppService.cs @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Linq; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Domain.Entities; @@ -8,18 +7,6 @@ using Volo.Abp.Linq; namespace Volo.Abp.Application.Services { - public abstract class AsyncCrudAppService - : AsyncCrudAppService - where TEntity : class, IEntity - where TEntityDto : IEntityDto - { - protected AsyncCrudAppService(IQueryableRepository repository) - : base(repository) - { - - } - } - public abstract class AsyncCrudAppService : AsyncCrudAppService where TEntity : class, IEntity @@ -49,7 +36,7 @@ namespace Volo.Abp.Application.Services where TGetAllInput : IPagedAndSortedResultRequest where TEntity : class, IEntity where TEntityDto : IEntityDto - where TCreateInput : IEntityDto + where TCreateInput : IEntityDto { protected AsyncCrudAppService(IQueryableRepository repository) : base(repository) diff --git a/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/CrudAppService.cs b/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/CrudAppService.cs index 127d0acd62..cec074f909 100644 --- a/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/CrudAppService.cs +++ b/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/CrudAppService.cs @@ -1,23 +1,10 @@ -using System; -using System.Linq; +using System.Linq; using Volo.Abp.Application.Dtos; using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories; namespace Volo.Abp.Application.Services { - public abstract class CrudAppService - : CrudAppService - where TEntity : class, IEntity - where TEntityDto : IEntityDto - { - protected CrudAppService(IQueryableRepository repository) - : base(repository) - { - - } - } - public abstract class CrudAppService : CrudAppService where TEntity : class, IEntity diff --git a/src/Volo.Abp.Ddd/Volo/Abp/Domain/Entities/Entity.cs b/src/Volo.Abp.Ddd/Volo/Abp/Domain/Entities/Entity.cs index 2ad2664f7d..185aad9767 100644 --- a/src/Volo.Abp.Ddd/Volo/Abp/Domain/Entities/Entity.cs +++ b/src/Volo.Abp.Ddd/Volo/Abp/Domain/Entities/Entity.cs @@ -5,7 +5,11 @@ namespace Volo.Abp.Domain.Entities /// public abstract class Entity : IEntity { - + /// + public override string ToString() + { + return $"[ENTITY: {GetType().Name}]"; + } } /// @@ -75,7 +79,7 @@ namespace Volo.Abp.Domain.Entities /// public override string ToString() { - return $"[{GetType().Name} {Id}]"; + return $"[ENTITY: {GetType().Name}] Id = {Id}"; } } } diff --git a/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleDto.cs b/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleDto.cs index cb48f53146..13aa96f41b 100644 --- a/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleDto.cs +++ b/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleDto.cs @@ -1,8 +1,9 @@ -using Volo.Abp.Application.Dtos; +using System; +using Volo.Abp.Application.Dtos; namespace Volo.Abp.Identity { - public class IdentityRoleDto : EntityDto + public class IdentityRoleDto : EntityDto { public string Name { get; set; } } diff --git a/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs b/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs index d2721a1911..a5a549545b 100644 --- a/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs +++ b/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs @@ -3,7 +3,7 @@ using Volo.Abp.Application.Dtos; namespace Volo.Abp.Identity { - public class IdentityUserDto : EntityDto + public class IdentityUserDto : EntityDto { public string UserName { get; set; } diff --git a/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/PersonAppService_Tests.cs b/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/PersonAppService_Tests.cs index cdf3b09bfa..7076cdd5e0 100644 --- a/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/PersonAppService_Tests.cs +++ b/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/PersonAppService_Tests.cs @@ -163,10 +163,10 @@ namespace Volo.Abp.AspNetCore.Mvc var douglas = _personRepository.First(p => p.Name == "Douglas"); var firstPhone = douglas.Phones.First(); - await Client.DeleteAsync($"/api/app/people/{douglas.Id}/phones/{firstPhone.Id}"); + await Client.DeleteAsync($"/api/app/people/{douglas.Id}/phones?number={firstPhone.Number}"); douglas = _personRepository.First(p => p.Name == "Douglas"); - douglas.Phones.Any(p => p.Id == firstPhone.Id).ShouldBeFalse(); + douglas.Phones.Any(p => p.Number == firstPhone.Number).ShouldBeFalse(); } } } \ No newline at end of file diff --git a/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/SampleClasses/MyEntityDto.cs b/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/SampleClasses/MyEntityDto.cs index 61e3e9b3bd..1d34d6858a 100644 --- a/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/SampleClasses/MyEntityDto.cs +++ b/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/SampleClasses/MyEntityDto.cs @@ -1,9 +1,10 @@ -using Volo.Abp.Application.Dtos; +using System; +using Volo.Abp.Application.Dtos; namespace Volo.Abp.AutoMapper.SampleClasses { [AutoMap(typeof(MyEntity))] - public class MyEntityDto : EntityDto + public class MyEntityDto : EntityDto { public int Number { get; set; } } diff --git a/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/SampleClasses/MyEntityDto2.cs b/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/SampleClasses/MyEntityDto2.cs index b01af5a7f9..ba67552ca0 100644 --- a/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/SampleClasses/MyEntityDto2.cs +++ b/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/SampleClasses/MyEntityDto2.cs @@ -1,8 +1,9 @@ +using System; using Volo.Abp.Application.Dtos; namespace Volo.Abp.AutoMapper.SampleClasses { - public class MyEntityDto2 : EntityDto + public class MyEntityDto2 : EntityDto { public int Number { get; set; } } diff --git a/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/SampleClasses/MyNotMappedDto.cs b/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/SampleClasses/MyNotMappedDto.cs index a69e50d819..096da7799c 100644 --- a/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/SampleClasses/MyNotMappedDto.cs +++ b/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/SampleClasses/MyNotMappedDto.cs @@ -1,8 +1,9 @@ -using Volo.Abp.Application.Dtos; +using System; +using Volo.Abp.Application.Dtos; namespace Volo.Abp.AutoMapper.SampleClasses { - public class MyNotMappedDto : EntityDto + public class MyNotMappedDto : EntityDto { public int Number { get; set; } } diff --git a/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/TestApp/EntityFrameworkCore/TestAppDbContext.cs b/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/TestApp/EntityFrameworkCore/TestAppDbContext.cs index f6088eb8a7..49deda972e 100644 --- a/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/TestApp/EntityFrameworkCore/TestAppDbContext.cs +++ b/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/TestApp/EntityFrameworkCore/TestAppDbContext.cs @@ -16,5 +16,15 @@ namespace Volo.Abp.TestApp.EntityFrameworkCore { } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity(b => + { + b.HasKey(p => new {p.PersonId, p.Number}); + }); + } } } diff --git a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/Dto/PersonDto.cs b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/Dto/PersonDto.cs index 7075c0c3c9..57204f260f 100644 --- a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/Dto/PersonDto.cs +++ b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/Dto/PersonDto.cs @@ -1,8 +1,9 @@ -using Volo.Abp.Application.Dtos; +using System; +using Volo.Abp.Application.Dtos; namespace Volo.Abp.TestApp.Application.Dto { - public class PersonDto : EntityDto + public class PersonDto : EntityDto { public string Name { get; set; } diff --git a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/Dto/PhoneDto.cs b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/Dto/PhoneDto.cs index 203d4f5054..a71da2940a 100644 --- a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/Dto/PhoneDto.cs +++ b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/Dto/PhoneDto.cs @@ -1,9 +1,8 @@ -using Volo.Abp.Application.Dtos; -using Volo.Abp.TestApp.Domain; +using Volo.Abp.TestApp.Domain; namespace Volo.Abp.TestApp.Application.Dto { - public class PhoneDto : EntityDto + public class PhoneDto { public string Number { get; set; } diff --git a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPeopleAppService.cs b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPeopleAppService.cs index e356d452a2..6317d7d8ce 100644 --- a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPeopleAppService.cs +++ b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPeopleAppService.cs @@ -12,7 +12,7 @@ namespace Volo.Abp.TestApp.Application Task AddPhone(Guid id, PhoneDto phoneDto); - Task RemovePhone(Guid id, long phoneId); + Task RemovePhone(Guid id, string number); Task GetWithComplexType(GetWithComplexTypeInput input); } diff --git a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PeopleAppService.cs b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PeopleAppService.cs index 7bc4ad087e..bd21d9cf3f 100644 --- a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PeopleAppService.cs +++ b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PeopleAppService.cs @@ -10,7 +10,7 @@ using Volo.Abp.TestApp.Application.Dto; namespace Volo.Abp.TestApp.Application { - public class PeopleAppService : AsyncCrudAppService, IPeopleAppService + public class PeopleAppService : AsyncCrudAppService, IPeopleAppService { public PeopleAppService(IQueryableRepository repository) : base(repository) @@ -39,10 +39,10 @@ namespace Volo.Abp.TestApp.Application return ObjectMapper.Map(phone); } - public async Task RemovePhone(Guid id, long phoneId) + public async Task RemovePhone(Guid id, string number) { var person = await GetEntityByIdAsync(id); - person.Phones.RemoveAll(p => p.Id == phoneId); + person.Phones.RemoveAll(p => p.Number == number); } public Task GetWithComplexType(GetWithComplexTypeInput input) diff --git a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Phone.cs b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Phone.cs index 8519bea092..45f31c705b 100644 --- a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Phone.cs +++ b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Phone.cs @@ -5,7 +5,7 @@ using Volo.Abp.Domain.Entities; namespace Volo.Abp.TestApp.Domain { [Table("AppPhones")] - public class Phone : Entity + public class Phone : Entity { public virtual Guid PersonId { get; set; }