Implemented a test entity without Id property.

pull/194/head
Halil İbrahim Kalkan 8 years ago
parent 5bd4c78bd8
commit d2da1f5a55

@ -1,33 +1,14 @@
using System;
namespace Volo.Abp.Application.Dtos
{
public class EntityDto : EntityDto<Guid>, IEntityDto
public class EntityDto : IEntityDto //TODO: Consider to delete this class
{
/// <summary>
/// Creates a new <see cref="EntityDto"/> object.
/// </summary>
public EntityDto()
{
}
/// <summary>
/// Creates a new <see cref="EntityDto"/> object.
/// </summary>
/// <param name="id">Id of the entity</param>
public EntityDto(Guid id)
: base(id)
public override string ToString()
{
return $"[DTO: {GetType().Name}]";
}
}
/// <summary>
/// Implements common properties for entity based DTOs.
/// </summary>
/// <typeparam name="TPrimaryKey">Type of the primary key</typeparam>
public class EntityDto<TPrimaryKey> : IEntityDto<TPrimaryKey>
public class EntityDto<TPrimaryKey> : EntityDto, IEntityDto<TPrimaryKey>
{
/// <summary>
/// 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}";
}
}
}

@ -1,24 +1,12 @@
using System;
namespace Volo.Abp.Application.Dtos
namespace Volo.Abp.Application.Dtos
{
/// <summary>
/// A shortcut of <see cref="IEntityDto{TPrimaryKey}"/> for default primary key type (<see cref="Guid"/>).
/// </summary>
public interface IEntityDto : IEntityDto<Guid>
public interface IEntityDto
{
}
/// <summary>
/// Defines common properties for entity based DTOs.
/// </summary>
/// <typeparam name="TPrimaryKey"></typeparam>
public interface IEntityDto<TPrimaryKey>
public interface IEntityDto<TPrimaryKey> : IEntityDto
{
/// <summary>
/// Id of the entity.
/// </summary>
TPrimaryKey Id { get; set; }
}
}

@ -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<TEntity, TEntityDto>
: AsyncCrudAppService<TEntity, TEntityDto, Guid>
where TEntity : class, IEntity<Guid>
where TEntityDto : IEntityDto<Guid>
{
protected AsyncCrudAppService(IQueryableRepository<TEntity, Guid> repository)
: base(repository)
{
}
}
public abstract class AsyncCrudAppService<TEntity, TEntityDto, TPrimaryKey>
: AsyncCrudAppService<TEntity, TEntityDto, TPrimaryKey, PagedAndSortedResultRequestDto>
where TEntity : class, IEntity<TPrimaryKey>
@ -49,7 +36,7 @@ namespace Volo.Abp.Application.Services
where TGetAllInput : IPagedAndSortedResultRequest
where TEntity : class, IEntity<TPrimaryKey>
where TEntityDto : IEntityDto<TPrimaryKey>
where TCreateInput : IEntityDto<TPrimaryKey>
where TCreateInput : IEntityDto<TPrimaryKey>
{
protected AsyncCrudAppService(IQueryableRepository<TEntity, TPrimaryKey> repository)
: base(repository)

@ -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<TEntity, TEntityDto>
: CrudAppService<TEntity, TEntityDto, Guid>
where TEntity : class, IEntity<Guid>
where TEntityDto : IEntityDto<Guid>
{
protected CrudAppService(IQueryableRepository<TEntity, Guid> repository)
: base(repository)
{
}
}
public abstract class CrudAppService<TEntity, TEntityDto, TPrimaryKey>
: CrudAppService<TEntity, TEntityDto, TPrimaryKey, PagedAndSortedResultRequestDto>
where TEntity : class, IEntity<TPrimaryKey>

@ -5,7 +5,11 @@ namespace Volo.Abp.Domain.Entities
/// <inheritdoc/>
public abstract class Entity : IEntity
{
/// <inheritdoc/>
public override string ToString()
{
return $"[ENTITY: {GetType().Name}]";
}
}
/// <inheritdoc cref="IEntity{TPrimaryKey}" />
@ -75,7 +79,7 @@ namespace Volo.Abp.Domain.Entities
/// <inheritdoc/>
public override string ToString()
{
return $"[{GetType().Name} {Id}]";
return $"[ENTITY: {GetType().Name}] Id = {Id}";
}
}
}

@ -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<Guid>
{
public string Name { get; set; }
}

@ -3,7 +3,7 @@ using Volo.Abp.Application.Dtos;
namespace Volo.Abp.Identity
{
public class IdentityUserDto : EntityDto
public class IdentityUserDto : EntityDto<Guid>
{
public string UserName { get; set; }

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

@ -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<Guid>
{
public int Number { get; set; }
}

@ -1,8 +1,9 @@
using System;
using Volo.Abp.Application.Dtos;
namespace Volo.Abp.AutoMapper.SampleClasses
{
public class MyEntityDto2 : EntityDto
public class MyEntityDto2 : EntityDto<Guid>
{
public int Number { get; set; }
}

@ -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<Guid>
{
public int Number { get; set; }
}

@ -16,5 +16,15 @@ namespace Volo.Abp.TestApp.EntityFrameworkCore
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Phone>(b =>
{
b.HasKey(p => new {p.PersonId, p.Number});
});
}
}
}

@ -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<Guid>
{
public string Name { get; set; }

@ -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<long>
public class PhoneDto
{
public string Number { get; set; }

@ -12,7 +12,7 @@ namespace Volo.Abp.TestApp.Application
Task<PhoneDto> AddPhone(Guid id, PhoneDto phoneDto);
Task RemovePhone(Guid id, long phoneId);
Task RemovePhone(Guid id, string number);
Task<GetWithComplexTypeInput> GetWithComplexType(GetWithComplexTypeInput input);
}

@ -10,7 +10,7 @@ using Volo.Abp.TestApp.Application.Dto;
namespace Volo.Abp.TestApp.Application
{
public class PeopleAppService : AsyncCrudAppService<Person, PersonDto>, IPeopleAppService
public class PeopleAppService : AsyncCrudAppService<Person, PersonDto, Guid>, IPeopleAppService
{
public PeopleAppService(IQueryableRepository<Person, Guid> repository)
: base(repository)
@ -39,10 +39,10 @@ namespace Volo.Abp.TestApp.Application
return ObjectMapper.Map<Phone, PhoneDto>(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<GetWithComplexTypeInput> GetWithComplexType(GetWithComplexTypeInput input)

@ -5,7 +5,7 @@ using Volo.Abp.Domain.Entities;
namespace Volo.Abp.TestApp.Domain
{
[Table("AppPhones")]
public class Phone : Entity<long>
public class Phone : Entity
{
public virtual Guid PersonId { get; set; }

Loading…
Cancel
Save