Skip to content

Commit

Permalink
Initial version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno de Souza Melo committed Feb 27, 2023
1 parent 1484849 commit c77b960
Show file tree
Hide file tree
Showing 16 changed files with 395 additions and 40 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*.cs]

# CS1591: Missing XML comment for publicly visible type or member
dotnet_diagnostic.CS1591.severity = none

# IDE0063: Use simple 'using' statement
dotnet_diagnostic.IDE0063.severity = none
52 changes: 16 additions & 36 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
Expand All @@ -13,23 +12,17 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Mono auto generated files
mono_crash.*

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/

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

# NUnit
# NUNIT
*.VisualState.xml
TestResult.xml
nunit-*.xml

# Build Results of an ATL Project
[Dd]ebugPS/
Expand All @@ -60,14 +52,15 @@ BenchmarkDotNet.Artifacts/
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json

# StyleCop
StyleCopReport.xml

# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*_i.h
*.ilk
*.meta
*.obj
Expand All @@ -84,7 +77,6 @@ StyleCopReport.xml
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
Expand Down Expand Up @@ -127,6 +119,9 @@ _ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

Expand Down Expand Up @@ -184,8 +179,6 @@ PublishScripts/

# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
Expand All @@ -210,14 +203,12 @@ BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
!*.[Cc]ache/

# Others
ClientBin/
Expand All @@ -230,7 +221,7 @@ ClientBin/
*.publishsettings
orleans.codegen.cs

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

Expand Down Expand Up @@ -261,9 +252,6 @@ ServiceFabricBackup/
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl

# Microsoft Fakes
FakesAssemblies/
Expand Down Expand Up @@ -299,8 +287,12 @@ paket-files/
# FAKE - F# Make
.fake/

# CodeRush personal settings
.cr/personal
# JetBrains Rider
.idea/
*.sln.iml

# CodeRush
.cr/

# Python Tools for Visual Studio (PTVS)
__pycache__/
Expand All @@ -325,7 +317,7 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/

# Azure Stream Analytics local run output
# Azure Stream Analytics local run output
ASALocalRun/

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

# MFractors (Xamarin productivity tool) working folder
# MFractors (Xamarin productivity tool) working folder
.mfractor/

# Local History for Visual Studio
.localhistory/

# BeatPulse healthcheck temp database
healthchecksdb

# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/
8 changes: 5 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
MIT License
The MIT License (MIT)

Copyright (c) 2023 Nuv Tools
Copyright (c) Nuv Tools

All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +20,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
44 changes: 44 additions & 0 deletions NuvTools.AspNetCore.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FFE8529B-55C4-4E15-B937-A6FEE1E9C5BA}"
ProjectSection(SolutionItems) = preProject
docs\Publishing.txt = docs\Publishing.txt
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0553FC7C-D8CC-444A-970D-CB3B064020F5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{3BD96AEC-23A5-44DF-ABBE-82E683AB587E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NuvTools.AspNetCore", "src\NuvTools.AspNetCore\NuvTools.AspNetCore.csproj", "{77571ABE-3EF7-403F-ACCC-68B539B02AB6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NuvTools.AspNetCore.EntityFrameworkCore", "src\NuvTools.AspNetCore.EntityFrameworkCore\NuvTools.AspNetCore.EntityFrameworkCore.csproj", "{A4C3BE0D-A233-4026-9AE9-8B1395418E1A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{77571ABE-3EF7-403F-ACCC-68B539B02AB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{77571ABE-3EF7-403F-ACCC-68B539B02AB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{77571ABE-3EF7-403F-ACCC-68B539B02AB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{77571ABE-3EF7-403F-ACCC-68B539B02AB6}.Release|Any CPU.Build.0 = Release|Any CPU
{A4C3BE0D-A233-4026-9AE9-8B1395418E1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4C3BE0D-A233-4026-9AE9-8B1395418E1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4C3BE0D-A233-4026-9AE9-8B1395418E1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4C3BE0D-A233-4026-9AE9-8B1395418E1A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{77571ABE-3EF7-403F-ACCC-68B539B02AB6} = {0553FC7C-D8CC-444A-970D-CB3B064020F5}
{A4C3BE0D-A233-4026-9AE9-8B1395418E1A} = {0553FC7C-D8CC-444A-970D-CB3B064020F5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BF8E6A9B-D224-46ED-9C99-E6DD796B4CC9}
EndGlobalSection
EndGlobal
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# nuvtools-aspnetcore
# Nuv Tools ASP.NET Core Libraries

Libraries with helpers to use with ASP.NET Aplications.

## NuvTools.AspNetCore

Common library with helpers to use with ASP.NET Aplications.

## NuvTools.AspNetCore.EntityFramework

EntityFramework Core helper library to use with ASP.NET Aplications.
2 changes: 2 additions & 0 deletions docs/Publishing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nuget.exe push -Source "nuvtools" -ApiKey az NuvTools.AspNetCore.7.0.0.nupkg
nuget.exe push -Source "nuvtools" -ApiKey az NuvTools.AspNetCore.EntityFrameworkCore.7.0.0.nupkg
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

namespace NuvTools.AspNetCore.EntityFrameworkCore.Extensions;

public static class ApplicationBuilderExtensions
{
public static IApplicationBuilder DatabaseMigrate<TContext>(this IApplicationBuilder app) where TContext : DbContext
{
using var serviceScope = app.ApplicationServices.CreateScope();
var context = serviceScope.ServiceProvider.GetService<TContext>();
if (context != null && context.Database != null)
{
context.Database.Migrate();
}

return app;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using NuvTools.AspNetCore.Mapper;
using NuvTools.Common.ResultWrapper;
using NuvTools.Data.EntityFrameworkCore.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace NuvTools.AspNetCore.EntityFrameworkCore.Mapper;

public abstract class ServiceWithCrudBase<TContext, TForm, TData, TKey> : ServiceWithMapperBase<TForm, TData>
where TForm : class
where TData : class
where TContext : DbContext
{
protected readonly TContext Context;

public ServiceWithCrudBase(TContext context, IMapper mapper) : base(mapper)
{
Context = context;
}

public DbSet<TData> Dataset { get { return Context.Set<TData>(); } }

public async Task<TForm> FindAsync(TKey id)
{
return ConvertToForm(await Context.FindAsync<TData>(id));
}

public async Task<TForm> FindAsync(object[] keys)
{
return ConvertToForm(await Context.FindAsync<TData>(keys));
}

public async Task<IEnumerable<TForm>> FindFromExpressionAsync(Expression<Func<IQueryable<TData>>> expression)
{
return ConvertToForm(await Context.FromExpression(expression).ToListAsync());
}

public virtual async Task<IResult<TKey>> AddAndSaveAsync(TForm model)
{
return await Context.AddAndSaveAsync<TData, TKey>(ConvertToData(model));
}

public virtual async Task<IResult> UpdateAndSaveAsync(TKey id, TForm model)
{
return await Context.UpdateAndSaveAsync(ConvertToData(model), id);
}

public virtual async Task<IResult> RemoveAndSaveAsync(TKey id)
{
return await Context.RemoveAndSaveAsync<TData>(id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Nuv Tools</Authors>
<Copyright>Copyright © 2023 Nuv Tools</Copyright>
<PackageProjectUrl>https://nuv.tools</PackageProjectUrl>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>NuvTools.AspNetCore.EntityFrameworkCore.snk</AssemblyOriginatorKeyFile>
<Description>EntityFramework Core helper library to use with ASP.NET Aplications.</Description>
<Version>7.0.0</Version>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<PackageIcon>icon.png</PackageIcon>
<DelaySign>False</DelaySign>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<RepositoryUrl>https://github.com/nuvtools/nuvtools-aspnetcore</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<AnalysisLevel>latest</AnalysisLevel>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>Nuv Tools AspNetCore Entity Framework Core</PackageTags>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.3" />
<PackageReference Include="NuvTools.Data.EntityFrameworkCore" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\icon.png">
<Link>icon.png</Link>
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Include="..\..\LICENSE">
<Link>LICENSE</Link>
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Include="..\..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\NuvTools.AspNetCore\NuvTools.AspNetCore.csproj" />
</ItemGroup>

</Project>
Binary file not shown.
Loading

0 comments on commit c77b960

Please sign in to comment.