diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..75bd10e --- /dev/null +++ b/.gitignore @@ -0,0 +1,400 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# 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/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +bin/* +Bin/* +obj/* +Obj/* +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +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. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +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/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# 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/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml diff --git a/.vs/AOLBackend/DesignTimeBuild/.dtbcache.v2 b/.vs/AOLBackend/DesignTimeBuild/.dtbcache.v2 index e1017c3..aebb0b7 100644 Binary files a/.vs/AOLBackend/DesignTimeBuild/.dtbcache.v2 and b/.vs/AOLBackend/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/AOLBackend/FileContentIndex/635a8ac5-26f8-4655-b28a-b3d233f0e011.vsidx b/.vs/AOLBackend/FileContentIndex/635a8ac5-26f8-4655-b28a-b3d233f0e011.vsidx deleted file mode 100644 index c87a3a2..0000000 Binary files a/.vs/AOLBackend/FileContentIndex/635a8ac5-26f8-4655-b28a-b3d233f0e011.vsidx and /dev/null differ diff --git a/.vs/AOLBackend/FileContentIndex/e0d51d11-d39d-4042-bc60-6530b9b12e45.vsidx b/.vs/AOLBackend/FileContentIndex/e0d51d11-d39d-4042-bc60-6530b9b12e45.vsidx deleted file mode 100644 index 664ddb0..0000000 Binary files a/.vs/AOLBackend/FileContentIndex/e0d51d11-d39d-4042-bc60-6530b9b12e45.vsidx and /dev/null differ diff --git a/.vs/AOLBackend/FileContentIndex/f11c721e-7551-48be-be97-96c2b0308372.vsidx b/.vs/AOLBackend/FileContentIndex/f11c721e-7551-48be-be97-96c2b0308372.vsidx deleted file mode 100644 index 62dd8e2..0000000 Binary files a/.vs/AOLBackend/FileContentIndex/f11c721e-7551-48be-be97-96c2b0308372.vsidx and /dev/null differ diff --git a/.vs/AOLBackend/v17/.futdcache.v1 b/.vs/AOLBackend/v17/.futdcache.v1 index 7643412..af6705c 100644 Binary files a/.vs/AOLBackend/v17/.futdcache.v1 and b/.vs/AOLBackend/v17/.futdcache.v1 differ diff --git a/.vs/AOLBackend/v17/.suo b/.vs/AOLBackend/v17/.suo index 357a1a9..c7cdc67 100644 Binary files a/.vs/AOLBackend/v17/.suo and b/.vs/AOLBackend/v17/.suo differ diff --git a/.vs/ProjectEvaluation/aolbackend.metadata.v2 b/.vs/ProjectEvaluation/aolbackend.metadata.v2 index 5a43037..3cbd18f 100644 Binary files a/.vs/ProjectEvaluation/aolbackend.metadata.v2 and b/.vs/ProjectEvaluation/aolbackend.metadata.v2 differ diff --git a/.vs/ProjectEvaluation/aolbackend.projects.v2 b/.vs/ProjectEvaluation/aolbackend.projects.v2 index d4bd408..218ede1 100644 Binary files a/.vs/ProjectEvaluation/aolbackend.projects.v2 and b/.vs/ProjectEvaluation/aolbackend.projects.v2 differ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..1f30fb7 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,36 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/net6.0/AOLBackend.dll", + "args": [], + "cwd": "${workspaceFolder}", + "stopAtEntry": false, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+https?://\\S+", + "uriFormat": "https://localhost:7000/swagger/index.html" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..e8f94ed --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/AOLBackend.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/AOLBackend.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/AOLBackend.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Contracts/Catalogos/ICatClientesRepository.cs b/Contracts/Catalogos/ICatClientesRepository.cs new file mode 100644 index 0000000..d009c7c --- /dev/null +++ b/Contracts/Catalogos/ICatClientesRepository.cs @@ -0,0 +1,11 @@ +using AOLBackend.Models.Catalogos; + +namespace AOLBackend.Contracts.Catalogos +{ + public interface ICatClientesRepository + { + public Task Append(ICatClientes data); + public Task> GetAll(); + public Task Delete(int id); + } +} \ No newline at end of file diff --git a/Controllers/Catalogos/CatClientesController.cs b/Controllers/Catalogos/CatClientesController.cs new file mode 100644 index 0000000..a30dce3 --- /dev/null +++ b/Controllers/Catalogos/CatClientesController.cs @@ -0,0 +1,44 @@ +using AOLBackend.Contracts.Catalogos; +using AOLBackend.DTO; +using AOLBackend.DTO.Usuario; +using AOLBackend.Models.Catalogos; +using Microsoft.AspNetCore.Mvc; + +namespace AOLBackend.Controllers.Catalogos +{ + [ApiController] + [Route("api/Catalogos/[controller]")] + public class CatClientesController : ControllerBase + { + private readonly ICatClientesRepository _Repo; + + public CatClientesController(ICatClientesRepository Repo) + { + _Repo = Repo; + } + + [HttpPost] + [Route("Append")] + public async Task Append([FromBody] ICatClientes data) + { + var entrada = await _Repo.Append(data); + return entrada; + } + + [HttpGet] + [Route("Get")] + public async Task> GetAll() + { + var entrada = await _Repo.GetAll(); + return entrada; + } + + [HttpDelete("Delete/{id}")] + public async Task Delete(int id) + { + await _Repo.Delete(id); + return new OkObjectResult(new { respuesta = "Se elimino el registro" }); + } + + } +} \ No newline at end of file diff --git a/Models/Catalogos/ICatClientes.cs b/Models/Catalogos/ICatClientes.cs new file mode 100644 index 0000000..3c1c70a --- /dev/null +++ b/Models/Catalogos/ICatClientes.cs @@ -0,0 +1,9 @@ +namespace AOLBackend.Models.Catalogos +{ + public class ICatClientes + { + public int id { get; set; } = 0; + public string Cliente { get; set; } = null!; + public Byte Activo { get; set; } = 0!; + } +} \ No newline at end of file diff --git a/Models/Catalogos/ICatProveedores.cs b/Models/Catalogos/ICatProveedores.cs new file mode 100644 index 0000000..9dab571 --- /dev/null +++ b/Models/Catalogos/ICatProveedores.cs @@ -0,0 +1,9 @@ +namespace AOLBackend.Models.Catalogos +{ + public class ICatProveedores + { + public int Id { get; set; } + public string Proveedor { get; set; } = null!; + public Byte Activo { get; set; } = 0!; + } +} \ No newline at end of file diff --git a/Models/Catalogos/IOrigenDestino.cs b/Models/Catalogos/IOrigenDestino.cs new file mode 100644 index 0000000..fd6b3ed --- /dev/null +++ b/Models/Catalogos/IOrigenDestino.cs @@ -0,0 +1,9 @@ +namespace AOLBackend.Models.Catalogos +{ + public class IOrigenDestino + { + public int Id { get; set; } + public string Ubicacion { get; set; } = null!; + public Byte Activo { get; set; } = 0!; + } +} \ No newline at end of file diff --git a/Program.cs b/Program.cs index 72171b2..8c4ebea 100644 --- a/Program.cs +++ b/Program.cs @@ -1,6 +1,8 @@ using AOLBackend.Context; using AOLBackend.Contracts; +using AOLBackend.Contracts.Catalogos; using AOLBackend.Repository; +using AOLBackend.Repository.Catalogos; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Tokens; using System.Text; @@ -8,7 +10,7 @@ using System.Text; var builder = WebApplication.CreateBuilder(args); builder.Services.AddSingleton(); builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddControllers(); builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options => diff --git a/Repository/Catalogos/CatClientesRepository.cs b/Repository/Catalogos/CatClientesRepository.cs new file mode 100644 index 0000000..d990f83 --- /dev/null +++ b/Repository/Catalogos/CatClientesRepository.cs @@ -0,0 +1,50 @@ +using AOLBackend.Context; +using AOLBackend.Contracts.Catalogos; +using AOLBackend.DTO; +using AOLBackend.DTO.Usuario; +using AOLBackend.Models.Catalogos; +using AOLBackend.Services.Tools; +using Dapper; +using System.Data; + +namespace AOLBackend.Repository.Catalogos +{ + public class CatClientesRepository : ICatClientesRepository + { + private readonly DapperContext _context; + private readonly IConfiguration _config; + public CatClientesRepository(DapperContext context, IConfiguration config) + { + _context = context; + _config = config; + } + + public async Task Append(ICatClientes data) + { + var query = "[Catalogo.CatClientes.Append]"; + using var connection = _context.CreateConnection(); + var entrada = await connection.QueryAsync(query, new + { + @id = data.id, + @Cliente = data.Cliente, + }, commandType: CommandType.StoredProcedure); + return entrada.First(); + } + public async Task> GetAll() + { + var query = "[Catalogo.CatClientes.Get]"; + using var connection = _context.CreateConnection(); + var entrada = await connection.QueryAsync(query, new { }, commandType: CommandType.StoredProcedure); + return entrada; + } + + public async Task Delete(int id) + { + var query = "[Catalogo.CatClientes.Delete]"; + using var connection = _context.CreateConnection(); + var entrada = await connection.QueryAsync(query, new { @id }, commandType: CommandType.StoredProcedure); + return true; + } + + } +} \ No newline at end of file diff --git a/Repository/UsuariosRepository.cs b/Repository/UsuariosRepository.cs index 13b27b2..bba5a97 100644 --- a/Repository/UsuariosRepository.cs +++ b/Repository/UsuariosRepository.cs @@ -64,9 +64,9 @@ namespace AOLBackend.Repository @HashContrasena = passwordCrypto, }, commandType: CommandType.StoredProcedure); IUsuarios userFound = usuarios.First(); - if (userFound == null) return userFound; + if (userFound == null) return userFound!; var hashed = CryptDecrypt.Decrypt(userFound.Contrasena); - if (hashed != user.Contrasena) return null; + if (hashed != user.Contrasena) return null!; return userFound; } } @@ -93,7 +93,7 @@ namespace AOLBackend.Repository @Contrasena = user.Contrasena, @HashContrasena = CryptDecrypt.Encrypt(user.Contrasena), }, commandType: CommandType.StoredProcedure); - if (usuarios.Count() == 0) return null; + if (usuarios.Count() == 0) return null!; var userFound = usuarios.First(); return userFound; } diff --git a/bin/Debug/net6.0/AOLBackend.dll b/bin/Debug/net6.0/AOLBackend.dll index 77758f3..56a481f 100644 Binary files a/bin/Debug/net6.0/AOLBackend.dll and b/bin/Debug/net6.0/AOLBackend.dll differ diff --git a/bin/Debug/net6.0/AOLBackend.pdb b/bin/Debug/net6.0/AOLBackend.pdb index 7144cbd..891cafe 100644 Binary files a/bin/Debug/net6.0/AOLBackend.pdb and b/bin/Debug/net6.0/AOLBackend.pdb differ diff --git a/obj/Debug/net6.0/AOLBackend.csproj.CoreCompileInputs.cache b/obj/Debug/net6.0/AOLBackend.csproj.CoreCompileInputs.cache index 54c49aa..edf33b7 100644 --- a/obj/Debug/net6.0/AOLBackend.csproj.CoreCompileInputs.cache +++ b/obj/Debug/net6.0/AOLBackend.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -dc389e70f51037c3ad713438898afdabc9e24613 +5c4d83d23e299243135bbd3e0f354dc85d91df62 diff --git a/obj/Debug/net6.0/AOLBackend.dll b/obj/Debug/net6.0/AOLBackend.dll index 77758f3..56a481f 100644 Binary files a/obj/Debug/net6.0/AOLBackend.dll and b/obj/Debug/net6.0/AOLBackend.dll differ diff --git a/obj/Debug/net6.0/AOLBackend.pdb b/obj/Debug/net6.0/AOLBackend.pdb index 7144cbd..891cafe 100644 Binary files a/obj/Debug/net6.0/AOLBackend.pdb and b/obj/Debug/net6.0/AOLBackend.pdb differ diff --git a/obj/Debug/net6.0/ref/AOLBackend.dll b/obj/Debug/net6.0/ref/AOLBackend.dll index 71d7093..0036f27 100644 Binary files a/obj/Debug/net6.0/ref/AOLBackend.dll and b/obj/Debug/net6.0/ref/AOLBackend.dll differ diff --git a/obj/Debug/net6.0/refint/AOLBackend.dll b/obj/Debug/net6.0/refint/AOLBackend.dll index 71d7093..0036f27 100644 Binary files a/obj/Debug/net6.0/refint/AOLBackend.dll and b/obj/Debug/net6.0/refint/AOLBackend.dll differ diff --git a/obj/staticwebassets.pack.sentinel b/obj/staticwebassets.pack.sentinel index 81879ad..a891214 100644 --- a/obj/staticwebassets.pack.sentinel +++ b/obj/staticwebassets.pack.sentinel @@ -20,3 +20,19 @@ 2.0 2.0 2.0 +2.0 +2.0 +2.0 +2.0 +2.0 +2.0 +2.0 +2.0 +2.0 +2.0 +2.0 +2.0 +2.0 +2.0 +2.0 +2.0