Skip to content

Commit 5682c02

Browse files
author
Bruno de Souza Melo
committed
Dependencies updated and naming fixes.
1 parent a6f6534 commit 5682c02

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

src/NuvTools.AspNetCore.EntityFrameworkCore/Mapper/ServiceWithCrudBase.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
namespace NuvTools.AspNetCore.EntityFrameworkCore.Mapper;
99

10-
public abstract class ServiceWithCrudBase<TContext, TForm, TData, TKey> : ServiceWithMapperBase<TForm, TData>
11-
where TForm : class
12-
where TData : class
10+
public abstract class ServiceWithCrudBase<TContext, TDTO, TEntity, TKey> : ServiceWithMapperBase<TDTO, TEntity>
11+
where TDTO : class
12+
where TEntity : class
1313
where TContext : DbContext
1414
{
1515
protected readonly TContext Context;
@@ -19,35 +19,35 @@ public ServiceWithCrudBase(TContext context, IMapper mapper) : base(mapper)
1919
Context = context;
2020
}
2121

22-
public DbSet<TData> Dataset { get { return Context.Set<TData>(); } }
22+
public DbSet<TEntity> Dataset { get { return Context.Set<TEntity>(); } }
2323

24-
public async Task<TForm> FindAsync(TKey id)
24+
public async Task<TDTO> FindAsync(TKey id)
2525
{
26-
return ConvertToForm(await Context.FindAsync<TData>(id));
26+
return ConvertToDTO(await Context.FindAsync<TEntity>(id));
2727
}
2828

29-
public async Task<TForm> FindAsync(object[] keys)
29+
public async Task<TDTO> FindAsync(object[] keys)
3030
{
31-
return ConvertToForm(await Context.FindAsync<TData>(keys));
31+
return ConvertToDTO(await Context.FindAsync<TEntity>(keys));
3232
}
3333

34-
public async Task<IEnumerable<TForm>> FindFromExpressionAsync(Expression<Func<IQueryable<TData>>> expression)
34+
public async Task<IEnumerable<TDTO>> FindFromExpressionAsync(Expression<Func<IQueryable<TEntity>>> expression)
3535
{
36-
return ConvertToForm(await Context.FromExpression(expression).ToListAsync());
36+
return ConvertToDTO(await Context.FromExpression(expression).ToListAsync());
3737
}
3838

39-
public virtual async Task<IResult<TKey>> AddAndSaveAsync(TForm model)
39+
public virtual async Task<IResult<TKey>> AddAndSaveAsync(TDTO model)
4040
{
41-
return await Context.AddAndSaveAsync<TData, TKey>(ConvertToData(model));
41+
return await Context.AddAndSaveAsync<TEntity, TKey>(ConvertToEntity(model));
4242
}
4343

44-
public virtual async Task<IResult> UpdateAndSaveAsync(TKey id, TForm model)
44+
public virtual async Task<IResult> UpdateAndSaveAsync(TKey id, TDTO model)
4545
{
46-
return await Context.UpdateAndSaveAsync(ConvertToData(model), id);
46+
return await Context.UpdateAndSaveAsync(ConvertToEntity(model), id);
4747
}
4848

4949
public virtual async Task<IResult> RemoveAndSaveAsync(TKey id)
5050
{
51-
return await Context.RemoveAndSaveAsync<TData>(id);
51+
return await Context.RemoveAndSaveAsync<TEntity>(id);
5252
}
5353
}

src/NuvTools.AspNetCore.EntityFrameworkCore/NuvTools.AspNetCore.EntityFrameworkCore.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<SignAssembly>True</SignAssembly>
1010
<AssemblyOriginatorKeyFile>NuvTools.AspNetCore.EntityFrameworkCore.snk</AssemblyOriginatorKeyFile>
1111
<Description>EntityFramework Core helper library to use with ASP.NET Aplications.</Description>
12-
<Version>8.0.0</Version>
12+
<Version>8.0.2</Version>
1313
<GenerateDocumentationFile>True</GenerateDocumentationFile>
1414
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
1515
<PackageIcon>icon.png</PackageIcon>
@@ -27,7 +27,7 @@
2727
<ItemGroup>
2828
<FrameworkReference Include="Microsoft.AspNetCore.App" />
2929

30-
<PackageReference Include="NuvTools.Data.EntityFrameworkCore" Version="8.0.0" />
30+
<PackageReference Include="NuvTools.Data.EntityFrameworkCore" Version="8.0.2" />
3131
</ItemGroup>
3232

3333
<ItemGroup Condition="'$(targetframework)' == 'net6'">

src/NuvTools.AspNetCore/Mapper/ServiceWithMapperBase.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace NuvTools.AspNetCore.Mapper;
44

5-
public abstract class ServiceWithMapperBase<TForm, TData> where TForm : class
6-
where TData : class
5+
public abstract class ServiceWithMapperBase<TDTO, TEntity> where TDTO : class
6+
where TEntity : class
77
{
88
private readonly IMapper _mapper;
99

@@ -22,39 +22,39 @@ public ServiceWithMapperBase(IMapper mapper)
2222

2323
#region Converter
2424

25-
protected TReturn ConvertTo<TReturn>(TData model)
25+
protected TReturn ConvertTo<TReturn>(TEntity model)
2626
{
2727
return _mapper.Map<TReturn>(model);
2828
}
2929

30-
protected IEnumerable<TReturn> ConvertTo<TReturn>(IEnumerable<TData> models)
30+
protected IEnumerable<TReturn> ConvertTo<TReturn>(IEnumerable<TEntity> models)
3131
{
3232
return _mapper.Map<IEnumerable<TReturn>>(models);
3333
}
3434

35-
protected TData ConvertToData(TForm model)
35+
protected TEntity ConvertToEntity(TDTO model)
3636
{
37-
return _mapper.Map<TData>(model);
37+
return _mapper.Map<TEntity>(model);
3838
}
3939

40-
protected TForm ConvertToForm(TData model)
40+
protected TDTO ConvertToDTO(TEntity model)
4141
{
42-
return _mapper.Map<TForm>(model);
42+
return _mapper.Map<TDTO>(model);
4343
}
4444

45-
protected IEnumerable<TForm> ConvertToForm(IEnumerable<TData> models)
46-
{
47-
return _mapper.Map<IEnumerable<TForm>>(models);
45+
protected IEnumerable<TDTO> ConvertToDTO(IEnumerable<TEntity> models)
46+
{
47+
return _mapper.Map<IEnumerable<TDTO>>(models);
4848
}
4949

50-
protected IList<TForm> ConvertToForm(IList<TData> models)
50+
protected IList<TDTO> ConvertToDTO(IList<TEntity> models)
5151
{
52-
return _mapper.Map<IList<TForm>>(models);
52+
return _mapper.Map<IList<TDTO>>(models);
5353
}
5454

55-
protected TForm[] ConvertToForm(TData[] models)
55+
protected TDTO[] ConvertToDTO(TEntity[] models)
5656
{
57-
return _mapper.Map<TForm[]>(models);
57+
return _mapper.Map<TDTO[]>(models);
5858
}
5959

6060
#endregion

src/NuvTools.AspNetCore/NuvTools.AspNetCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<SignAssembly>True</SignAssembly>
1010
<AssemblyOriginatorKeyFile>NuvTools.AspNetCore.snk</AssemblyOriginatorKeyFile>
1111
<Description>Common library with helpers to use with ASP.NET Aplications.</Description>
12-
<Version>8.0.0</Version>
12+
<Version>8.0.2</Version>
1313
<GenerateDocumentationFile>True</GenerateDocumentationFile>
1414
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
1515
<PackageIcon>icon.png</PackageIcon>

0 commit comments

Comments
 (0)