Skip to content

Commit c77b960

Browse files
author
Bruno de Souza Melo
committed
Initial version.
1 parent 1484849 commit c77b960

16 files changed

+395
-40
lines changed

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[*.cs]
2+
3+
# CS1591: Missing XML comment for publicly visible type or member
4+
dotnet_diagnostic.CS1591.severity = none
5+
6+
# IDE0063: Use simple 'using' statement
7+
dotnet_diagnostic.IDE0063.severity = none

.gitignore

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
55

66
# User-specific files
7-
*.rsuser
87
*.suo
98
*.user
109
*.userosscache
@@ -13,23 +12,17 @@
1312
# User-specific files (MonoDevelop/Xamarin Studio)
1413
*.userprefs
1514

16-
# Mono auto generated files
17-
mono_crash.*
18-
1915
# Build results
2016
[Dd]ebug/
2117
[Dd]ebugPublic/
2218
[Rr]elease/
2319
[Rr]eleases/
2420
x64/
2521
x86/
26-
[Aa][Rr][Mm]/
27-
[Aa][Rr][Mm]64/
2822
bld/
2923
[Bb]in/
3024
[Oo]bj/
3125
[Ll]og/
32-
[Ll]ogs/
3326

3427
# Visual Studio 2015/2017 cache/options directory
3528
.vs/
@@ -43,10 +36,9 @@ Generated\ Files/
4336
[Tt]est[Rr]esult*/
4437
[Bb]uild[Ll]og.*
4538

46-
# NUnit
39+
# NUNIT
4740
*.VisualState.xml
4841
TestResult.xml
49-
nunit-*.xml
5042

5143
# Build Results of an ATL Project
5244
[Dd]ebugPS/
@@ -60,14 +52,15 @@ BenchmarkDotNet.Artifacts/
6052
project.lock.json
6153
project.fragment.lock.json
6254
artifacts/
55+
**/Properties/launchSettings.json
6356

6457
# StyleCop
6558
StyleCopReport.xml
6659

6760
# Files built by Visual Studio
6861
*_i.c
6962
*_p.c
70-
*_h.h
63+
*_i.h
7164
*.ilk
7265
*.meta
7366
*.obj
@@ -84,7 +77,6 @@ StyleCopReport.xml
8477
*.tlh
8578
*.tmp
8679
*.tmp_proj
87-
*_wpftmp.csproj
8880
*.log
8981
*.vspscc
9082
*.vssscc
@@ -127,6 +119,9 @@ _ReSharper*/
127119
*.[Rr]e[Ss]harper
128120
*.DotSettings.user
129121

122+
# JustCode is a .NET coding add-in
123+
.JustCode
124+
130125
# TeamCity is a build add-in
131126
_TeamCity*
132127

@@ -184,8 +179,6 @@ PublishScripts/
184179

185180
# NuGet Packages
186181
*.nupkg
187-
# NuGet Symbol Packages
188-
*.snupkg
189182
# The packages folder can be ignored because of Package Restore
190183
**/[Pp]ackages/*
191184
# except build/, which is used as an MSBuild target.
@@ -210,14 +203,12 @@ BundleArtifacts/
210203
Package.StoreAssociation.xml
211204
_pkginfo.txt
212205
*.appx
213-
*.appxbundle
214-
*.appxupload
215206

216207
# Visual Studio cache files
217208
# files ending in .cache can be ignored
218209
*.[Cc]ache
219210
# but keep track of directories ending in .cache
220-
!?*.[Cc]ache/
211+
!*.[Cc]ache/
221212

222213
# Others
223214
ClientBin/
@@ -230,7 +221,7 @@ ClientBin/
230221
*.publishsettings
231222
orleans.codegen.cs
232223

233-
# Including strong name files can present a security risk
224+
# Including strong name files can present a security risk
234225
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
235226
#*.snk
236227

@@ -261,9 +252,6 @@ ServiceFabricBackup/
261252
*.bim.layout
262253
*.bim_*.settings
263254
*.rptproj.rsuser
264-
*- [Bb]ackup.rdl
265-
*- [Bb]ackup ([0-9]).rdl
266-
*- [Bb]ackup ([0-9][0-9]).rdl
267255

268256
# Microsoft Fakes
269257
FakesAssemblies/
@@ -299,8 +287,12 @@ paket-files/
299287
# FAKE - F# Make
300288
.fake/
301289

302-
# CodeRush personal settings
303-
.cr/personal
290+
# JetBrains Rider
291+
.idea/
292+
*.sln.iml
293+
294+
# CodeRush
295+
.cr/
304296

305297
# Python Tools for Visual Studio (PTVS)
306298
__pycache__/
@@ -325,7 +317,7 @@ __pycache__/
325317
# OpenCover UI analysis results
326318
OpenCover/
327319

328-
# Azure Stream Analytics local run output
320+
# Azure Stream Analytics local run output
329321
ASALocalRun/
330322

331323
# MSBuild Binary and Structured Log
@@ -334,17 +326,5 @@ ASALocalRun/
334326
# NVidia Nsight GPU debugger configuration file
335327
*.nvuser
336328

337-
# MFractors (Xamarin productivity tool) working folder
329+
# MFractors (Xamarin productivity tool) working folder
338330
.mfractor/
339-
340-
# Local History for Visual Studio
341-
.localhistory/
342-
343-
# BeatPulse healthcheck temp database
344-
healthchecksdb
345-
346-
# Backup folder for Package Reference Convert tool in Visual Studio 2017
347-
MigrationBackup/
348-
349-
# Ionide (cross platform F# VS Code tools) working folder
350-
.ionide/

LICENSE

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
MIT License
1+
The MIT License (MIT)
22

3-
Copyright (c) 2023 Nuv Tools
3+
Copyright (c) Nuv Tools
4+
5+
All rights reserved.
46

57
Permission is hereby granted, free of charge, to any person obtaining a copy
68
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +20,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1820
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1921
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2022
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
23+
SOFTWARE.

NuvTools.AspNetCore.sln

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.3.32929.385
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FFE8529B-55C4-4E15-B937-A6FEE1E9C5BA}"
7+
ProjectSection(SolutionItems) = preProject
8+
docs\Publishing.txt = docs\Publishing.txt
9+
EndProjectSection
10+
EndProject
11+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0553FC7C-D8CC-444A-970D-CB3B064020F5}"
12+
EndProject
13+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{3BD96AEC-23A5-44DF-ABBE-82E683AB587E}"
14+
EndProject
15+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NuvTools.AspNetCore", "src\NuvTools.AspNetCore\NuvTools.AspNetCore.csproj", "{77571ABE-3EF7-403F-ACCC-68B539B02AB6}"
16+
EndProject
17+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NuvTools.AspNetCore.EntityFrameworkCore", "src\NuvTools.AspNetCore.EntityFrameworkCore\NuvTools.AspNetCore.EntityFrameworkCore.csproj", "{A4C3BE0D-A233-4026-9AE9-8B1395418E1A}"
18+
EndProject
19+
Global
20+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
21+
Debug|Any CPU = Debug|Any CPU
22+
Release|Any CPU = Release|Any CPU
23+
EndGlobalSection
24+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
25+
{77571ABE-3EF7-403F-ACCC-68B539B02AB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{77571ABE-3EF7-403F-ACCC-68B539B02AB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{77571ABE-3EF7-403F-ACCC-68B539B02AB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
28+
{77571ABE-3EF7-403F-ACCC-68B539B02AB6}.Release|Any CPU.Build.0 = Release|Any CPU
29+
{A4C3BE0D-A233-4026-9AE9-8B1395418E1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30+
{A4C3BE0D-A233-4026-9AE9-8B1395418E1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
31+
{A4C3BE0D-A233-4026-9AE9-8B1395418E1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
32+
{A4C3BE0D-A233-4026-9AE9-8B1395418E1A}.Release|Any CPU.Build.0 = Release|Any CPU
33+
EndGlobalSection
34+
GlobalSection(SolutionProperties) = preSolution
35+
HideSolutionNode = FALSE
36+
EndGlobalSection
37+
GlobalSection(NestedProjects) = preSolution
38+
{77571ABE-3EF7-403F-ACCC-68B539B02AB6} = {0553FC7C-D8CC-444A-970D-CB3B064020F5}
39+
{A4C3BE0D-A233-4026-9AE9-8B1395418E1A} = {0553FC7C-D8CC-444A-970D-CB3B064020F5}
40+
EndGlobalSection
41+
GlobalSection(ExtensibilityGlobals) = postSolution
42+
SolutionGuid = {BF8E6A9B-D224-46ED-9C99-E6DD796B4CC9}
43+
EndGlobalSection
44+
EndGlobal

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1-
# nuvtools-aspnetcore
1+
# Nuv Tools ASP.NET Core Libraries
2+
23
Libraries with helpers to use with ASP.NET Aplications.
4+
5+
## NuvTools.AspNetCore
6+
7+
Common library with helpers to use with ASP.NET Aplications.
8+
9+
## NuvTools.AspNetCore.EntityFramework
10+
11+
EntityFramework Core helper library to use with ASP.NET Aplications.

docs/Publishing.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
nuget.exe push -Source "nuvtools" -ApiKey az NuvTools.AspNetCore.7.0.0.nupkg
2+
nuget.exe push -Source "nuvtools" -ApiKey az NuvTools.AspNetCore.EntityFrameworkCore.7.0.0.nupkg

icon.png

2.12 KB
Loading
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.EntityFrameworkCore;
3+
using Microsoft.Extensions.DependencyInjection;
4+
5+
namespace NuvTools.AspNetCore.EntityFrameworkCore.Extensions;
6+
7+
public static class ApplicationBuilderExtensions
8+
{
9+
public static IApplicationBuilder DatabaseMigrate<TContext>(this IApplicationBuilder app) where TContext : DbContext
10+
{
11+
using var serviceScope = app.ApplicationServices.CreateScope();
12+
var context = serviceScope.ServiceProvider.GetService<TContext>();
13+
if (context != null && context.Database != null)
14+
{
15+
context.Database.Migrate();
16+
}
17+
18+
return app;
19+
}
20+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using AutoMapper;
2+
using Microsoft.EntityFrameworkCore;
3+
using NuvTools.AspNetCore.Mapper;
4+
using NuvTools.Common.ResultWrapper;
5+
using NuvTools.Data.EntityFrameworkCore.Extensions;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Linq;
9+
using System.Linq.Expressions;
10+
using System.Threading.Tasks;
11+
12+
namespace NuvTools.AspNetCore.EntityFrameworkCore.Mapper;
13+
14+
public abstract class ServiceWithCrudBase<TContext, TForm, TData, TKey> : ServiceWithMapperBase<TForm, TData>
15+
where TForm : class
16+
where TData : class
17+
where TContext : DbContext
18+
{
19+
protected readonly TContext Context;
20+
21+
public ServiceWithCrudBase(TContext context, IMapper mapper) : base(mapper)
22+
{
23+
Context = context;
24+
}
25+
26+
public DbSet<TData> Dataset { get { return Context.Set<TData>(); } }
27+
28+
public async Task<TForm> FindAsync(TKey id)
29+
{
30+
return ConvertToForm(await Context.FindAsync<TData>(id));
31+
}
32+
33+
public async Task<TForm> FindAsync(object[] keys)
34+
{
35+
return ConvertToForm(await Context.FindAsync<TData>(keys));
36+
}
37+
38+
public async Task<IEnumerable<TForm>> FindFromExpressionAsync(Expression<Func<IQueryable<TData>>> expression)
39+
{
40+
return ConvertToForm(await Context.FromExpression(expression).ToListAsync());
41+
}
42+
43+
public virtual async Task<IResult<TKey>> AddAndSaveAsync(TForm model)
44+
{
45+
return await Context.AddAndSaveAsync<TData, TKey>(ConvertToData(model));
46+
}
47+
48+
public virtual async Task<IResult> UpdateAndSaveAsync(TKey id, TForm model)
49+
{
50+
return await Context.UpdateAndSaveAsync(ConvertToData(model), id);
51+
}
52+
53+
public virtual async Task<IResult> RemoveAndSaveAsync(TKey id)
54+
{
55+
return await Context.RemoveAndSaveAsync<TData>(id);
56+
}
57+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net6;net7</TargetFrameworks>
5+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
6+
<Authors>Nuv Tools</Authors>
7+
<Copyright>Copyright © 2023 Nuv Tools</Copyright>
8+
<PackageProjectUrl>https://nuv.tools</PackageProjectUrl>
9+
<SignAssembly>True</SignAssembly>
10+
<AssemblyOriginatorKeyFile>NuvTools.AspNetCore.EntityFrameworkCore.snk</AssemblyOriginatorKeyFile>
11+
<Description>EntityFramework Core helper library to use with ASP.NET Aplications.</Description>
12+
<Version>7.0.0</Version>
13+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
14+
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
15+
<PackageIcon>icon.png</PackageIcon>
16+
<DelaySign>False</DelaySign>
17+
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
18+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
19+
<RepositoryUrl>https://github.com/nuvtools/nuvtools-aspnetcore</RepositoryUrl>
20+
<RepositoryType>git</RepositoryType>
21+
<AnalysisLevel>latest</AnalysisLevel>
22+
<PackageReadmeFile>README.md</PackageReadmeFile>
23+
<PackageTags>Nuv Tools AspNetCore Entity Framework Core</PackageTags>
24+
<ImplicitUsings>true</ImplicitUsings>
25+
</PropertyGroup>
26+
27+
<ItemGroup>
28+
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
29+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.3" />
30+
<PackageReference Include="NuvTools.Data.EntityFrameworkCore" Version="7.0.0" />
31+
</ItemGroup>
32+
33+
<ItemGroup>
34+
<None Include="..\..\icon.png">
35+
<Link>icon.png</Link>
36+
<Pack>True</Pack>
37+
<PackagePath></PackagePath>
38+
</None>
39+
<None Include="..\..\LICENSE">
40+
<Link>LICENSE</Link>
41+
<Pack>True</Pack>
42+
<PackagePath></PackagePath>
43+
</None>
44+
<None Include="..\..\README.md">
45+
<Pack>True</Pack>
46+
<PackagePath>\</PackagePath>
47+
</None>
48+
</ItemGroup>
49+
50+
<ItemGroup>
51+
<ProjectReference Include="..\NuvTools.AspNetCore\NuvTools.AspNetCore.csproj" />
52+
</ItemGroup>
53+
54+
</Project>

0 commit comments

Comments
 (0)