diff --git a/BookManager/.gitignore b/BookManager/.gitignore
new file mode 100644
index 00000000..f2bf2899
--- /dev/null
+++ b/BookManager/.gitignore
@@ -0,0 +1,456 @@
+## 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/master/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/
+[Bb]in/
+[Oo]bj/
+[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
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# Tye
+.tye/
+
+# 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
+*.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 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/
+
+# 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
+
+##
+## Visual studio for Mac
+##
+
+
+# globs
+Makefile.in
+*.userprefs
+*.usertasks
+config.make
+config.status
+aclocal.m4
+install-sh
+autom4te.cache/
+*.tar.gz
+tarballs/
+test-results/
+
+# Mac bundle stuff
+*.dmg
+*.app
+
+# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
+# General
+.DS_Store
+.AppleDouble
+.LSOverride
+
+# Icon must end with two \r
+Icon
+
+
+# Thumbnails
+._*
+
+# Files that might appear in the root of a volume
+.DocumentRevisions-V100
+.fseventsd
+.Spotlight-V100
+.TemporaryItems
+.Trashes
+.VolumeIcon.icns
+.com.apple.timemachine.donotpresent
+
+# Directories potentially created on remote AFP share
+.AppleDB
+.AppleDesktop
+Network Trash Folder
+Temporary Items
+.apdisk
+
+# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
+# Windows thumbnail cache files
+Thumbs.db
+ehthumbs.db
+ehthumbs_vista.db
+
+# Dump file
+*.stackdump
+
+# Folder config file
+[Dd]esktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# Windows Installer files
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# Windows shortcuts
+*.lnk
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+##
+## Visual Studio Code
+##
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+.vscode
+vscode
\ No newline at end of file
diff --git a/BookManager/BookManager.csproj b/BookManager/BookManager.csproj
new file mode 100644
index 00000000..82d94e45
--- /dev/null
+++ b/BookManager/BookManager.csproj
@@ -0,0 +1,28 @@
+
+
+
+ net6.0
+ enable
+ enable
+ enable
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
+
diff --git a/BookManager/Controllers/AuthContoller.cs b/BookManager/Controllers/AuthContoller.cs
new file mode 100644
index 00000000..139c67a1
--- /dev/null
+++ b/BookManager/Controllers/AuthContoller.cs
@@ -0,0 +1,77 @@
+using BookManager.Model;
+using BookManager.Repository.Interfaces;
+using BookManager.Services;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+
+namespace BookManager.Controllers
+{
+ [ApiController]
+ [Route("api/[controller]")]
+ public class AuthController : ControllerBase
+ {
+
+ private readonly IUserRepository repository;
+
+ public AuthController(IUserRepository pRepository)
+ {
+ repository = pRepository;
+ }
+
+ [AllowAnonymous]
+ [HttpPost("login")]
+ public async Task login(Credential param)
+ {
+ if (param == null ||
+ string.IsNullOrWhiteSpace(param.email) ||
+ string.IsNullOrWhiteSpace(param.password))
+ {
+ //Logger.LogInformation("Dados Inválidos");
+ return BadRequest("Dados Inválidos");
+ }
+
+
+ var user = await repository.login(param);
+
+
+
+ if (user != null && !string.IsNullOrWhiteSpace(user.name))
+ {
+ Token token = new TokenService().GenerateToken(user);
+ return Ok(token);
+ }
+ else
+ {
+
+ return NotFound("User not found.");
+ }
+
+ }
+
+
+ [AllowAnonymous]
+ [HttpPost("signup")]
+ public async Task signup(User user)
+ {
+
+ if (user == null ||
+ string.IsNullOrWhiteSpace(user.name) ||
+ string.IsNullOrWhiteSpace(user.email) ||
+ string.IsNullOrWhiteSpace(user.password) ||
+ string.IsNullOrWhiteSpace(user.role))
+ return BadRequest("Dados Inválidos");
+ if (await repository.checkUserExists(user))
+ return BadRequest("User exists.");
+
+ repository.Add(user);
+
+ return await repository.SaveChangesAsync()
+ ? Ok("User adicionado com sucesso")
+ : BadRequest("Erro ao salvar o Usuario");
+
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Controllers/BooksController.cs b/BookManager/Controllers/BooksController.cs
new file mode 100644
index 00000000..a10786d3
--- /dev/null
+++ b/BookManager/Controllers/BooksController.cs
@@ -0,0 +1,269 @@
+using BookManager.Model;
+using BookManager.Repository.Interfaces;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using System.Reflection;
+
+namespace BookManager.Controllers
+{
+ [ApiController]
+ [Route("api/[controller]")]
+ public class BooksController : ControllerBase
+ {
+
+ private readonly IBookRepository repository;
+ private readonly ICostomLogRepository costomLogRepository;
+
+ public BooksController(IBookRepository pRepository, ICostomLogRepository pCostomLogRepository)
+ {
+ repository = pRepository;
+ costomLogRepository = pCostomLogRepository;
+ }
+ [AllowAnonymous]
+ [HttpGet]
+ public async Task Get()
+ {
+
+ try
+ {
+ var books = await repository.GetBooksAsync();
+ if (books != null && books.Any())
+ {
+ return Ok(books);
+ }
+ else
+ {
+
+ return NotFound("Books not exiists");
+ }
+ }
+ catch (Exception ex)
+ {
+ logger("Get", ex.ToString());
+ return BadRequest(ex.Message);
+ }
+ }
+
+
+ [AllowAnonymous]
+ [HttpGet("GetFilter/skip/{skip:int}/take/{take:int}/name/{name}")]
+ public async Task GetFilter(
+ [FromRoute] int skip = 0,
+ [FromRoute] int take = 50,
+ [FromRoute] string name = "")
+ {
+ try
+ {
+ var books = await repository.GetFilter(skip, take, name);
+
+ if (books != null && books.Any())
+ {
+ int pCount = repository.getCountBook(name);
+ return Ok(new
+ {
+ skip = skip,
+ take = take,
+ count = pCount,
+ data = books
+ });
+ }
+ else
+ {
+ return NotFound("Books not exists");
+ }
+ }
+ catch (Exception ex)
+ {
+ logger("GetFilter", ex.ToString());
+ return BadRequest(ex.Message);
+ }
+ }
+
+
+ [AllowAnonymous]
+ [HttpGet("id/{id:int}")]
+ public async Task GetById(int id)
+ {
+ try
+ {
+ if (id <= 0)
+ {
+ return NotFound("Id Not Found");
+ }
+
+
+ var book = await repository.GetBooksByIdAsync(id);
+ return book != null
+ ? Ok(book)
+ : NotFound("Book not found");
+ }
+ catch (Exception ex)
+ {
+ logger("GetById", ex.ToString());
+ return BadRequest(ex.Message);
+ }
+ }
+
+
+ [Authorize]
+ [HttpPut]
+ public async Task put(Book book)
+ {
+
+ try
+ {
+ if (book == null) return BadRequest("Dados Inválidos");
+
+ var bookDB = await repository.GetBooksByIdAsync(book.id);
+ if (string.IsNullOrWhiteSpace(book.decription))
+ {
+ bookDB.decription = book.decription;
+ }
+ if (string.IsNullOrWhiteSpace(book.author))
+ {
+ bookDB.author = book.author;
+ }
+ if (string.IsNullOrWhiteSpace(book.name))
+ {
+ bookDB.name = book.name;
+ }
+ if (string.IsNullOrWhiteSpace(book.isnb))
+ {
+ bookDB.isnb = book.isnb;
+ }
+ repository.Update(bookDB);
+
+ return await repository.SaveChangesAsync()
+ ? Ok("Book Alterado com sucesso")
+ : BadRequest("Erro ao salvar book");
+ }
+ catch (Exception ex)
+ {
+ logger("Put", ex.ToString());
+ return BadRequest(ex.Message);
+ }
+
+ }
+
+ [Authorize]
+ [HttpDelete("id/{id:int}")]
+ public async Task delete(int id)
+ {
+ try
+ {
+ var book = await repository.GetBooksByIdAsync(id);
+ repository.Delete(book);
+
+ return await repository.SaveChangesAsync()
+ ? Ok("Book excluido com sucesso.")
+ : BadRequest("Erro ao excluir o book.");
+ }
+ catch (Exception ex)
+ {
+ logger("delete", ex.ToString());
+ return BadRequest(ex.Message);
+ }
+ }
+
+ [Authorize]
+ [HttpPost]
+ public async Task Post(Book book)
+ {
+ try
+ {
+ if (book == null ||
+ string.IsNullOrWhiteSpace(book.name) ||
+ string.IsNullOrWhiteSpace(book.decription) ||
+ string.IsNullOrWhiteSpace(book.isnb) ||
+ string.IsNullOrWhiteSpace(book.author) ||
+ book.idCategory <= 0 ||
+ book.idPublisher <= 0 ||
+ book.year <= 0
+ )
+ {
+ return BadRequest("Dados Inválidos");
+ }
+
+ var checkExists = await repository.bookCheckExists(book);
+ if (checkExists)
+ {
+ return BadRequest("Book exists.");
+ }
+ repository.Add(book);
+
+ return await repository.SaveChangesAsync()
+ ? Ok("Book adicionado com sucesso")
+ : BadRequest("Erro ao salvar o book");
+ }
+ catch (Exception ex)
+ {
+ logger("Post", ex.ToString());
+ return BadRequest(ex.Message);
+ }
+
+
+ }
+
+ [Authorize]
+ [HttpGet("load/qtd/{qtd:int}")]
+ public async Task load(int qtd = 100)
+ {
+ try
+ {
+ bool controle = false;
+ if (qtd > 1000)
+ return BadRequest("Maximo 1000");
+
+ int max = await repository.getMaxIdBook();
+ for (int i = max + 1; i < (qtd + max + 1); i++)
+ {
+ var book = new Book
+ {
+
+ name = $"Nome Book {i}",
+ decription = $"Description book {i}",
+ author = "author",
+ idCategory = 1,
+ isnb = $"9999{i}",
+ year = 2004,
+ idPublisher = 1,
+ exemplary = i,
+ createAt = DateTime.Now
+
+ };
+ repository.Add(book);
+
+ }
+ controle = await repository.SaveChangesAsync();
+ return controle
+ ? Ok("Load com sucesso")
+ : BadRequest("Erro");
+ }
+ catch (Exception ex)
+ {
+ logger("Get", ex.ToString());
+ return BadRequest(ex.Message);
+ }
+
+ }
+
+ private async void logger(string pOperation, string pTrace)
+ {
+ try
+ {
+ var log = new CustomLog()
+ {
+ operation = String.Concat("bookController", pOperation).ToLower(),
+ trace = pTrace,
+ createAt = DateTime.Now
+ };
+ costomLogRepository.Add(log);
+ await costomLogRepository.SaveChangesAsync();
+ }
+ catch
+ {
+ //não sobe, grava no event viwer
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Data/DataContext.cs b/BookManager/Data/DataContext.cs
new file mode 100644
index 00000000..458e3fa0
--- /dev/null
+++ b/BookManager/Data/DataContext.cs
@@ -0,0 +1,126 @@
+using BookManager.Model;
+using Microsoft.EntityFrameworkCore;
+
+namespace BookManager.Data
+{
+ public class DataContext : DbContext
+ {
+ public DataContext(DbContextOptions options) : base(options)
+ {
+ AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
+ //AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
+ }
+ public DbSet Categorys { get; set; }
+ public DbSet Publishers { get; set; }
+ public DbSet Books { get; set; }
+ public DbSet Stocks { get; set; }
+ public DbSet Users { get; set; }
+ public DbSet CustomLogs { get; set; }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ //base.OnModelCreating(modelBuilder);
+ //modelBuilder.ApplyConfigurationsFromAssembly(GetType().Assembly);
+
+ modelBuilder.Entity().HasData(
+ new User
+ {
+ id = 5,
+ name = "Marcos Simões",
+ email = "Marcos@gmail.com",
+ password = "dat@s35",
+ role = "ADM"
+ },
+ new User
+ {
+ id = 6,
+ name = "Dantas Rocha",
+ email = "optedev@gmail.com",
+ password = "dat@s35",
+ role = "ADM"
+ }
+ );
+
+ modelBuilder.Entity().HasData(
+ new Category
+ {
+ id = 1,
+ desciption = "Livro Tecnico"
+ },
+ new Category
+ {
+ id = 2,
+ desciption = "Livro Informatica"
+ }
+ );
+ modelBuilder.Entity().HasData(
+ new Publisher
+ {
+ id = 1,
+ desciption = "Editora Books"
+ },
+ new Publisher
+ {
+ id = 2,
+ desciption = "EditoraBookman"
+ }
+ );
+ // modelBuilder.Entity().HasData(
+ // new Book
+ // {
+ // name = "Clean Code",
+ // decription = "Clean Code Agil",
+ // author = "",
+ // idCategory = 1,
+ // isnb = "111111111",
+ // year = 2004,
+ // idPublisher = 1,
+ // exemplary = 1
+
+ // },
+ // new Book
+ // {
+ // name = "Refactory",
+ // decription = "Refactory",
+ // author = "",
+ // idCategory = 1,
+ // isnb = "111111112",
+ // year = 2004,
+ // idPublisher = 2,
+ // exemplary = 1
+ // },
+ // new Book
+ // {
+ // name = "Clean Code",
+ // decription = "Clean Code Agil",
+ // author = "",
+ // idCategory = 1,
+ // isnb = "111111113",
+ // year = 2004,
+ // idPublisher = 1,
+ // exemplary = 1
+ // }
+ // );
+
+ // modelBuilder.Entity().HasData(
+ // new Stock
+ // {
+ // idBook = 1,
+ // quantity = 1000
+ // },
+ // new Stock
+ // {
+ // idBook = 2,
+ // quantity = 1000
+ // },
+ // new Stock
+ // {
+ // idBook = 3,
+ // quantity = 1000
+ // }
+ // );
+
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Migrations/20221117214404_MyFirstMigration.Designer.cs b/BookManager/Migrations/20221117214404_MyFirstMigration.Designer.cs
new file mode 100644
index 00000000..0e478695
--- /dev/null
+++ b/BookManager/Migrations/20221117214404_MyFirstMigration.Designer.cs
@@ -0,0 +1,136 @@
+//
+using BookManager.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace BookManager.Migrations
+{
+ [DbContext(typeof(DataContext))]
+ [Migration("20221117214404_MyFirstMigration")]
+ partial class MyFirstMigration
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.0")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("BookManager.Model.Book", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("decription")
+ .HasColumnType("text");
+
+ b.Property("idAuthor")
+ .HasColumnType("text");
+
+ b.Property("idCategory")
+ .HasColumnType("integer");
+
+ b.Property("idPublisher")
+ .HasColumnType("integer");
+
+ b.Property("isnb")
+ .HasColumnType("text");
+
+ b.Property("title")
+ .HasColumnType("text");
+
+ b.Property("year")
+ .HasColumnType("integer");
+
+ b.HasKey("id");
+
+ b.ToTable("Books");
+ });
+
+ modelBuilder.Entity("BookManager.Model.Category", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("desciption")
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("Categorys");
+ });
+
+ modelBuilder.Entity("BookManager.Model.Publisher", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("desciption")
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("Publishers");
+ });
+
+ modelBuilder.Entity("BookManager.Model.Stock", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("idBook")
+ .HasColumnType("integer");
+
+ b.Property("quantity")
+ .HasColumnType("integer");
+
+ b.HasKey("id");
+
+ b.ToTable("Stocks");
+ });
+
+ modelBuilder.Entity("BookManager.Model.User", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("email")
+ .HasColumnType("text");
+
+ b.Property("name")
+ .HasColumnType("text");
+
+ b.Property("password")
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("Users");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/BookManager/Migrations/20221117214404_MyFirstMigration.cs b/BookManager/Migrations/20221117214404_MyFirstMigration.cs
new file mode 100644
index 00000000..ffca4847
--- /dev/null
+++ b/BookManager/Migrations/20221117214404_MyFirstMigration.cs
@@ -0,0 +1,108 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace BookManager.Migrations
+{
+ ///
+ public partial class MyFirstMigration : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Books",
+ columns: table => new
+ {
+ id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ title = table.Column(type: "text", nullable: true),
+ decription = table.Column(type: "text", nullable: true),
+ idAuthor = table.Column(type: "text", nullable: true),
+ idCategory = table.Column(type: "integer", nullable: false),
+ isnb = table.Column(type: "text", nullable: true),
+ year = table.Column(type: "integer", nullable: false),
+ idPublisher = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Books", x => x.id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Categorys",
+ columns: table => new
+ {
+ id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ desciption = table.Column(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Categorys", x => x.id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Publishers",
+ columns: table => new
+ {
+ id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ desciption = table.Column(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Publishers", x => x.id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Stocks",
+ columns: table => new
+ {
+ id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ idBook = table.Column(type: "integer", nullable: false),
+ quantity = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Stocks", x => x.id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Users",
+ columns: table => new
+ {
+ id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ name = table.Column(type: "text", nullable: true),
+ email = table.Column(type: "text", nullable: true),
+ password = table.Column(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Users", x => x.id);
+ });
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Books");
+
+ migrationBuilder.DropTable(
+ name: "Categorys");
+
+ migrationBuilder.DropTable(
+ name: "Publishers");
+
+ migrationBuilder.DropTable(
+ name: "Stocks");
+
+ migrationBuilder.DropTable(
+ name: "Users");
+ }
+ }
+}
diff --git a/BookManager/Migrations/20221119183036_MyFirstMigration2.Designer.cs b/BookManager/Migrations/20221119183036_MyFirstMigration2.Designer.cs
new file mode 100644
index 00000000..46caa275
--- /dev/null
+++ b/BookManager/Migrations/20221119183036_MyFirstMigration2.Designer.cs
@@ -0,0 +1,143 @@
+//
+using BookManager.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace BookManager.Migrations
+{
+ [DbContext(typeof(DataContext))]
+ [Migration("20221119183036_MyFirstMigration2")]
+ partial class MyFirstMigration2
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.0")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("BookManager.Model.Book", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("decription")
+ .HasColumnType("text");
+
+ b.Property("idAuthor")
+ .HasColumnType("text");
+
+ b.Property("idCategory")
+ .HasColumnType("integer");
+
+ b.Property("idPublisher")
+ .HasColumnType("integer");
+
+ b.Property("isnb")
+ .HasColumnType("text");
+
+ b.Property("title")
+ .HasColumnType("text");
+
+ b.Property("year")
+ .HasColumnType("integer");
+
+ b.HasKey("id");
+
+ b.ToTable("Books");
+ });
+
+ modelBuilder.Entity("BookManager.Model.Category", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("desciption")
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("Categorys");
+ });
+
+ modelBuilder.Entity("BookManager.Model.Publisher", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("desciption")
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("Publishers");
+ });
+
+ modelBuilder.Entity("BookManager.Model.Stock", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("idBook")
+ .HasColumnType("integer");
+
+ b.Property("quantity")
+ .HasColumnType("integer");
+
+ b.HasKey("id");
+
+ b.ToTable("Stocks");
+ });
+
+ modelBuilder.Entity("BookManager.Model.User", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("email")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("password")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("role")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("Users");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/BookManager/Migrations/20221119183036_MyFirstMigration2.cs b/BookManager/Migrations/20221119183036_MyFirstMigration2.cs
new file mode 100644
index 00000000..21ba31c0
--- /dev/null
+++ b/BookManager/Migrations/20221119183036_MyFirstMigration2.cs
@@ -0,0 +1,83 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace BookManager.Migrations
+{
+ ///
+ public partial class MyFirstMigration2 : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterColumn(
+ name: "password",
+ table: "Users",
+ type: "text",
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "text",
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "name",
+ table: "Users",
+ type: "text",
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "text",
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "email",
+ table: "Users",
+ type: "text",
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "text",
+ oldNullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "role",
+ table: "Users",
+ type: "text",
+ nullable: false,
+ defaultValue: "");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "role",
+ table: "Users");
+
+ migrationBuilder.AlterColumn(
+ name: "password",
+ table: "Users",
+ type: "text",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "text");
+
+ migrationBuilder.AlterColumn(
+ name: "name",
+ table: "Users",
+ type: "text",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "text");
+
+ migrationBuilder.AlterColumn(
+ name: "email",
+ table: "Users",
+ type: "text",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "text");
+ }
+ }
+}
diff --git a/BookManager/Migrations/20221119184147_MyFirstMigration3.Designer.cs b/BookManager/Migrations/20221119184147_MyFirstMigration3.Designer.cs
new file mode 100644
index 00000000..f05892aa
--- /dev/null
+++ b/BookManager/Migrations/20221119184147_MyFirstMigration3.Designer.cs
@@ -0,0 +1,147 @@
+//
+using BookManager.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace BookManager.Migrations
+{
+ [DbContext(typeof(DataContext))]
+ [Migration("20221119184147_MyFirstMigration3")]
+ partial class MyFirstMigration3
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.0")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("BookManager.Model.Book", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("Author")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("decription")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("idCategory")
+ .HasColumnType("integer");
+
+ b.Property("idPublisher")
+ .HasColumnType("integer");
+
+ b.Property("isnb")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("title")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("year")
+ .HasColumnType("integer");
+
+ b.HasKey("id");
+
+ b.ToTable("Books");
+ });
+
+ modelBuilder.Entity("BookManager.Model.Category", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("desciption")
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("Categorys");
+ });
+
+ modelBuilder.Entity("BookManager.Model.Publisher", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("desciption")
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("Publishers");
+ });
+
+ modelBuilder.Entity("BookManager.Model.Stock", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("idBook")
+ .HasColumnType("integer");
+
+ b.Property("quantity")
+ .HasColumnType("integer");
+
+ b.HasKey("id");
+
+ b.ToTable("Stocks");
+ });
+
+ modelBuilder.Entity("BookManager.Model.User", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("email")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("password")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("role")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("Users");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/BookManager/Migrations/20221119184147_MyFirstMigration3.cs b/BookManager/Migrations/20221119184147_MyFirstMigration3.cs
new file mode 100644
index 00000000..b50b9e5a
--- /dev/null
+++ b/BookManager/Migrations/20221119184147_MyFirstMigration3.cs
@@ -0,0 +1,93 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace BookManager.Migrations
+{
+ ///
+ public partial class MyFirstMigration3 : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "idAuthor",
+ table: "Books");
+
+ migrationBuilder.AlterColumn(
+ name: "title",
+ table: "Books",
+ type: "text",
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "text",
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "isnb",
+ table: "Books",
+ type: "text",
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "text",
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "decription",
+ table: "Books",
+ type: "text",
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "text",
+ oldNullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "Author",
+ table: "Books",
+ type: "text",
+ nullable: false,
+ defaultValue: "");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "Author",
+ table: "Books");
+
+ migrationBuilder.AlterColumn(
+ name: "title",
+ table: "Books",
+ type: "text",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "text");
+
+ migrationBuilder.AlterColumn(
+ name: "isnb",
+ table: "Books",
+ type: "text",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "text");
+
+ migrationBuilder.AlterColumn(
+ name: "decription",
+ table: "Books",
+ type: "text",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "text");
+
+ migrationBuilder.AddColumn(
+ name: "idAuthor",
+ table: "Books",
+ type: "text",
+ nullable: true);
+ }
+ }
+}
diff --git a/BookManager/Migrations/20221121002120_Migration4.Designer.cs b/BookManager/Migrations/20221121002120_Migration4.Designer.cs
new file mode 100644
index 00000000..6b9b0662
--- /dev/null
+++ b/BookManager/Migrations/20221121002120_Migration4.Designer.cs
@@ -0,0 +1,222 @@
+//
+using System;
+using BookManager.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace BookManager.Migrations
+{
+ [DbContext(typeof(DataContext))]
+ [Migration("20221121002120_Migration4")]
+ partial class Migration4
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.0")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("BookManager.Model.Book", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("author")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("createAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("decription")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("exemplary")
+ .HasColumnType("integer");
+
+ b.Property("idCategory")
+ .HasColumnType("integer");
+
+ b.Property("idPublisher")
+ .HasColumnType("integer");
+
+ b.Property("isnb")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("year")
+ .HasColumnType("integer");
+
+ b.HasKey("id");
+
+ b.ToTable("Books");
+ });
+
+ modelBuilder.Entity("BookManager.Model.Category", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("desciption")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("Categorys");
+
+ b.HasData(
+ new
+ {
+ id = 1,
+ desciption = "Livro Tecnico"
+ },
+ new
+ {
+ id = 2,
+ desciption = "Livro Informatica"
+ });
+ });
+
+ modelBuilder.Entity("BookManager.Model.CustomLog", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("createAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("operation")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("trace")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("CustomLogs");
+ });
+
+ modelBuilder.Entity("BookManager.Model.Publisher", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("desciption")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("Publishers");
+
+ b.HasData(
+ new
+ {
+ id = 1,
+ desciption = "Editora Books"
+ },
+ new
+ {
+ id = 2,
+ desciption = "EditoraBookman"
+ });
+ });
+
+ modelBuilder.Entity("BookManager.Model.Stock", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("idBook")
+ .HasColumnType("integer");
+
+ b.Property("quantity")
+ .HasColumnType("integer");
+
+ b.HasKey("id");
+
+ b.ToTable("Stocks");
+ });
+
+ modelBuilder.Entity("BookManager.Model.User", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("email")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("password")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("role")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("Users");
+
+ b.HasData(
+ new
+ {
+ id = 5,
+ email = "Marcos@gmail.com",
+ name = "Marcos Simões",
+ password = "dat@s35",
+ role = "ADM"
+ },
+ new
+ {
+ id = 6,
+ email = "optedev@gmail.com",
+ name = "Dantas Rocha",
+ password = "dat@s35",
+ role = "ADM"
+ });
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/BookManager/Migrations/20221121002120_Migration4.cs b/BookManager/Migrations/20221121002120_Migration4.cs
new file mode 100644
index 00000000..9867ff1e
--- /dev/null
+++ b/BookManager/Migrations/20221121002120_Migration4.cs
@@ -0,0 +1,175 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
+
+namespace BookManager.Migrations
+{
+ ///
+ public partial class Migration4 : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.RenameColumn(
+ name: "Author",
+ table: "Books",
+ newName: "author");
+
+ migrationBuilder.RenameColumn(
+ name: "title",
+ table: "Books",
+ newName: "name");
+
+ migrationBuilder.AlterColumn(
+ name: "desciption",
+ table: "Publishers",
+ type: "text",
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "text",
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "desciption",
+ table: "Categorys",
+ type: "text",
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "text",
+ oldNullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "createAt",
+ table: "Books",
+ type: "timestamp with time zone",
+ nullable: false,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+
+ migrationBuilder.AddColumn(
+ name: "exemplary",
+ table: "Books",
+ type: "integer",
+ nullable: false,
+ defaultValue: 0);
+
+ migrationBuilder.CreateTable(
+ name: "CustomLogs",
+ columns: table => new
+ {
+ id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ operation = table.Column(type: "text", nullable: false),
+ trace = table.Column(type: "text", nullable: false),
+ createAt = table.Column(type: "timestamp with time zone", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_CustomLogs", x => x.id);
+ });
+
+ migrationBuilder.InsertData(
+ table: "Categorys",
+ columns: new[] { "id", "desciption" },
+ values: new object[,]
+ {
+ { 1, "Livro Tecnico" },
+ { 2, "Livro Informatica" }
+ });
+
+ migrationBuilder.InsertData(
+ table: "Publishers",
+ columns: new[] { "id", "desciption" },
+ values: new object[,]
+ {
+ { 1, "Editora Books" },
+ { 2, "EditoraBookman" }
+ });
+
+ migrationBuilder.InsertData(
+ table: "Users",
+ columns: new[] { "id", "email", "name", "password", "role" },
+ values: new object[,]
+ {
+ { 5, "Marcos@gmail.com", "Marcos Simões", "dat@s35", "ADM" },
+ { 6, "optedev@gmail.com", "Dantas Rocha", "dat@s35", "ADM" }
+ });
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "CustomLogs");
+
+ migrationBuilder.DeleteData(
+ table: "Categorys",
+ keyColumn: "id",
+ keyValue: 1);
+
+ migrationBuilder.DeleteData(
+ table: "Categorys",
+ keyColumn: "id",
+ keyValue: 2);
+
+ migrationBuilder.DeleteData(
+ table: "Publishers",
+ keyColumn: "id",
+ keyValue: 1);
+
+ migrationBuilder.DeleteData(
+ table: "Publishers",
+ keyColumn: "id",
+ keyValue: 2);
+
+ migrationBuilder.DeleteData(
+ table: "Users",
+ keyColumn: "id",
+ keyValue: 5);
+
+ migrationBuilder.DeleteData(
+ table: "Users",
+ keyColumn: "id",
+ keyValue: 6);
+
+ migrationBuilder.DropColumn(
+ name: "createAt",
+ table: "Books");
+
+ migrationBuilder.DropColumn(
+ name: "exemplary",
+ table: "Books");
+
+ migrationBuilder.RenameColumn(
+ name: "author",
+ table: "Books",
+ newName: "Author");
+
+ migrationBuilder.RenameColumn(
+ name: "name",
+ table: "Books",
+ newName: "title");
+
+ migrationBuilder.AlterColumn(
+ name: "desciption",
+ table: "Publishers",
+ type: "text",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "text");
+
+ migrationBuilder.AlterColumn(
+ name: "desciption",
+ table: "Categorys",
+ type: "text",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "text");
+ }
+ }
+}
diff --git a/BookManager/Migrations/DataContextModelSnapshot.cs b/BookManager/Migrations/DataContextModelSnapshot.cs
new file mode 100644
index 00000000..9e47f75b
--- /dev/null
+++ b/BookManager/Migrations/DataContextModelSnapshot.cs
@@ -0,0 +1,219 @@
+//
+using System;
+using BookManager.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace BookManager.Migrations
+{
+ [DbContext(typeof(DataContext))]
+ partial class DataContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.0")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("BookManager.Model.Book", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("author")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("createAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("decription")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("exemplary")
+ .HasColumnType("integer");
+
+ b.Property("idCategory")
+ .HasColumnType("integer");
+
+ b.Property("idPublisher")
+ .HasColumnType("integer");
+
+ b.Property("isnb")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("year")
+ .HasColumnType("integer");
+
+ b.HasKey("id");
+
+ b.ToTable("Books");
+ });
+
+ modelBuilder.Entity("BookManager.Model.Category", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("desciption")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("Categorys");
+
+ b.HasData(
+ new
+ {
+ id = 1,
+ desciption = "Livro Tecnico"
+ },
+ new
+ {
+ id = 2,
+ desciption = "Livro Informatica"
+ });
+ });
+
+ modelBuilder.Entity("BookManager.Model.CustomLog", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("createAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("operation")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("trace")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("CustomLogs");
+ });
+
+ modelBuilder.Entity("BookManager.Model.Publisher", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("desciption")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("Publishers");
+
+ b.HasData(
+ new
+ {
+ id = 1,
+ desciption = "Editora Books"
+ },
+ new
+ {
+ id = 2,
+ desciption = "EditoraBookman"
+ });
+ });
+
+ modelBuilder.Entity("BookManager.Model.Stock", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("idBook")
+ .HasColumnType("integer");
+
+ b.Property("quantity")
+ .HasColumnType("integer");
+
+ b.HasKey("id");
+
+ b.ToTable("Stocks");
+ });
+
+ modelBuilder.Entity("BookManager.Model.User", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id"));
+
+ b.Property("email")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("password")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("role")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("id");
+
+ b.ToTable("Users");
+
+ b.HasData(
+ new
+ {
+ id = 5,
+ email = "Marcos@gmail.com",
+ name = "Marcos Simões",
+ password = "dat@s35",
+ role = "ADM"
+ },
+ new
+ {
+ id = 6,
+ email = "optedev@gmail.com",
+ name = "Dantas Rocha",
+ password = "dat@s35",
+ role = "ADM"
+ });
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/BookManager/Model/Book.cs b/BookManager/Model/Book.cs
new file mode 100644
index 00000000..d2c9bdc3
--- /dev/null
+++ b/BookManager/Model/Book.cs
@@ -0,0 +1,44 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace BookManager.Model
+{
+ public class Book
+ {
+
+ public Book()
+ {
+ name = string.Empty;
+ decription = string.Empty;
+ author = string.Empty;
+ isnb = string.Empty;
+ }
+
+
+ [Key]
+ [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+ public int id { get; set; }
+ [Required]
+ public string name { get; set; }
+ [Required]
+ public string decription { get; set; }
+ [Required]
+ public string author { get; set; }
+ [Required]
+ public int idCategory { get; set; }
+ [Required]
+ public string isnb { get; set; }
+ [Required]
+ public int year { get; set; }
+ [Required]
+ public int idPublisher { get; set; }
+ [Required]
+ public DateTime createAt { get; set; }
+
+ [Required]
+ public int exemplary { get; set; }
+
+
+
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Model/BookFilter.cs b/BookManager/Model/BookFilter.cs
new file mode 100644
index 00000000..36ec8eb7
--- /dev/null
+++ b/BookManager/Model/BookFilter.cs
@@ -0,0 +1,19 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace BookManager.Model
+{
+ public class BookFilter
+ {
+ public BookFilter()
+ {
+ name = string.Empty;
+ decription = string.Empty;
+ author = string.Empty;
+ }
+ public string? name { get; set; }
+ public string? decription { get; set; }
+ public string? author { get; set; }
+
+
+ }
+}
diff --git a/BookManager/Model/Category.cs b/BookManager/Model/Category.cs
new file mode 100644
index 00000000..1d33b7fa
--- /dev/null
+++ b/BookManager/Model/Category.cs
@@ -0,0 +1,12 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace BookManager.Model
+{
+ public class Category
+ {
+ [Required]
+ public int id { get; set; }
+ [Required]
+ public string? desciption { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Model/Credential.cs b/BookManager/Model/Credential.cs
new file mode 100644
index 00000000..10e71222
--- /dev/null
+++ b/BookManager/Model/Credential.cs
@@ -0,0 +1,18 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace BookManager.Model
+{
+ public class Credential
+ {
+ public Credential()
+ {
+ email = string.Empty;
+ password = string.Empty;
+ }
+
+ [Required]
+ public string email { get; set; }
+ [Required]
+ public string password { get; set; }
+ }
+}
diff --git a/BookManager/Model/CustomLog.cs b/BookManager/Model/CustomLog.cs
new file mode 100644
index 00000000..27a9193c
--- /dev/null
+++ b/BookManager/Model/CustomLog.cs
@@ -0,0 +1,24 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace BookManager.Model
+{
+ public class CustomLog
+ {
+ public CustomLog()
+ {
+ operation = string.Empty;
+ trace = string.Empty;
+ }
+ [Key]
+ [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+ public int id { get; set; }
+ [Required]
+ public string operation { get; set; }
+ [Required]
+ public string trace { get; set; }
+ [Required]
+ public DateTime createAt { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Model/Publisher.cs b/BookManager/Model/Publisher.cs
new file mode 100644
index 00000000..414a91e5
--- /dev/null
+++ b/BookManager/Model/Publisher.cs
@@ -0,0 +1,13 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace BookManager.Model
+{
+ public class Publisher
+ {
+
+ [Required]
+ public int id { get; set; }
+ [Required]
+ public string? desciption { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Model/Token.cs b/BookManager/Model/Token.cs
new file mode 100644
index 00000000..a63de91c
--- /dev/null
+++ b/BookManager/Model/Token.cs
@@ -0,0 +1,12 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace BookManager.Model
+{
+ public class Token
+ {
+ [Required]
+ public string? token { get; set; }
+ [Required]
+ public DateTime expires { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Model/User.cs b/BookManager/Model/User.cs
new file mode 100644
index 00000000..c96e2b8d
--- /dev/null
+++ b/BookManager/Model/User.cs
@@ -0,0 +1,29 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace BookManager.Model
+{
+ public class User
+ {
+
+ public User()
+ {
+ name = string.Empty;
+ email = string.Empty;
+ password = string.Empty;
+ role = string.Empty;
+ }
+
+ [Key]
+ [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+ public int id { get; set; }
+ [Required]
+ public string name { get; set; }
+ [Required]
+ public string email { get; set; }
+ [Required]
+ public string password { get; set; }
+ [Required]
+ public string role { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Model/stock.cs b/BookManager/Model/stock.cs
new file mode 100644
index 00000000..6e90012d
--- /dev/null
+++ b/BookManager/Model/stock.cs
@@ -0,0 +1,17 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace BookManager.Model
+{
+ public class Stock
+ {
+ [Key]
+ [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+ [Required]
+ public int id { get; set; }
+ [Required]
+ public int idBook { get; set; }
+ [Required]
+ public int quantity { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Program.cs b/BookManager/Program.cs
new file mode 100644
index 00000000..1357da64
--- /dev/null
+++ b/BookManager/Program.cs
@@ -0,0 +1,111 @@
+using BookManager.Data;
+using BookManager.Repository;
+using BookManager.Repository.Interfaces;
+using Microsoft.EntityFrameworkCore;
+using System.Text.Json.Serialization;
+using Microsoft.Extensions.Options;
+using Microsoft.OpenApi.Models;
+using System.Text;
+using Microsoft.AspNetCore.Authentication.JwtBearer;
+using Microsoft.IdentityModel.Tokens;
+using BookManager.Services;
+using BookManager.Model;
+
+var builder = WebApplication.CreateBuilder(args);
+ConfigureAuthentication(builder);
+
+
+// Add services to the container.
+
+//builder.Services.AddControllers();
+
+builder.Services.AddControllers().AddJsonOptions(options =>
+{
+ options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
+});
+
+
+builder.Services.AddControllers();
+
+builder.Services.AddEndpointsApiExplorer();
+//builder.Services.AddSwaggerGen();
+builder.Services.AddSwaggerGen(c =>
+{
+ c.SwaggerDoc("v1", new OpenApiInfo { Title = "APIBookManager", Version = "v1" });
+
+ c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
+ {
+ Description =
+ "JWT Authorization Header - utilizado com Bearer Authentication.\r\n\r\n" +
+ "Digite 'Bearer' [espaço] e então seu token no campo abaixo.\r\n\r\n" +
+ "Exemplo (informar sem as aspas): 'Bearer 12345abcdef'",
+ Name = "Authorization",
+ In = ParameterLocation.Header,
+ Type = SecuritySchemeType.ApiKey,
+ Scheme = "Bearer",
+ BearerFormat = "JWT",
+ });
+
+ c.AddSecurityRequirement(new OpenApiSecurityRequirement
+ {
+ {
+ new OpenApiSecurityScheme
+ {
+ Reference = new OpenApiReference
+ {
+ Type = ReferenceType.SecurityScheme,
+ Id = "Bearer"
+ }
+ },
+ Array.Empty()
+ }
+ });
+});
+
+builder.Services.AddEntityFrameworkNpgsql()
+ .AddDbContext(options =>
+ options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
+
+builder.Services.AddScoped();
+builder.Services.AddScoped();
+builder.Services.AddScoped();
+
+var app = builder.Build();
+
+// Configure the HTTP request pipeline.
+if (app.Environment.IsDevelopment())
+{
+ app.UseSwagger();
+ app.UseSwaggerUI();
+}
+
+app.UseHttpsRedirection();
+app.UseHttpLogging();
+
+
+app.UseAuthentication();
+app.UseAuthorization();
+
+app.MapControllers();
+
+app.Run();
+
+void ConfigureAuthentication(WebApplicationBuilder builder)
+{
+ var key = Encoding.ASCII.GetBytes(Settins.secret);
+ builder.Services.AddAuthentication(x =>
+ {
+ x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
+ x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
+ }).AddJwtBearer(x =>
+ {
+ x.TokenValidationParameters = new TokenValidationParameters
+ {
+ ValidateIssuerSigningKey = true,
+ IssuerSigningKey = new SymmetricSecurityKey(key),
+ ValidateIssuer = false,
+ ValidateAudience = false
+ };
+ });
+}
+
diff --git a/BookManager/Properties/launchSettings.json b/BookManager/Properties/launchSettings.json
new file mode 100644
index 00000000..ecf3b0fe
--- /dev/null
+++ b/BookManager/Properties/launchSettings.json
@@ -0,0 +1,31 @@
+{
+ "$schema": "https://json.schemastore.org/launchsettings.json",
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:10226",
+ "sslPort": 44355
+ }
+ },
+ "profiles": {
+ "BookManager": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "applicationUrl": "https://localhost:7102;http://localhost:5153",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/BookManager/README.md b/BookManager/README.md
new file mode 100644
index 00000000..47168f5b
--- /dev/null
+++ b/BookManager/README.md
@@ -0,0 +1,111 @@
+# BookManager Test
+
+This application is generated using C# And Visual Studio Code
+
+Projeto para controle de livros
+
+## Dependencies
+
+- Microsoft.EntityFrameworkCore
+
+```sh
+dotnet restore
+Database Postgre
+Set Conect string in appsettings.json
+dotnet ef database update --context DataContext
+```
+
+## Run the application
+
+```sh
+dotnet run
+```
+
+## Tests
+
+```sh
+Coleção do postman anexa no projeto
+
+```
+
+## Ecosistema da Api
+
+```
+
+Ide de desenvolvimento Visual Code
+Linguagem C#
+.Net FrameWork 6
+Docker-distribuição
+Banco postegrer (mas poderia seu oracle ou sqlserver)
+Construção do banco EF-Migrations
+Distribuição - Docker
+Autenticação e autorização: JWT
+Documentação da Api - Swegger
+Teste Api - Postman (Collection anexa)
+Revisão de codigo foi utilisado a extensão eslint
+Padroes de projeto:(explicitar )
+ - Factory src/service/factory.report.ts
+ - Singleton src/services/singleton.ts
+ - injeção de dependencia -> src/services/
+ - Princípio de responsabilidade única -> src/services/
+
+
+```
+
+## Trello atividades
+
+```sh
+
+#1 - Analise e entendimento da demanda
+#2 - Dividir para conquistar - dividir o projeto em atividades via trello
+#3 - Validar escopo
+#4 - Criar setup do projeto
+#5 - Gerar o Diagrama classes
+#6 - criar a base de dados
+#7 - Criar os migrates
+#8 - Criar os seeds
+#9 - configurar o docker
+#10- Gerar os modelos
+#11- gerar as controller-limpar
+#13- Configurar jwt
+#15- Gerar Chave
+#16- Testar e refatorar
+#17- Atualizar o Re
+#18- Validações
+#19-pipline
+
+```
+
+## Check List Macro
+
+```sh
+
+- Modelagem DR -OK
+- Swagger - OK
+- Jwt -OK
+- gitignore -OK
+- injeção de dependencia -ok
+- Princípio de responsabilidade única -ok
+- Entity -ok
+- Crud-OK
+- Banco Pstegre -ok
+- Migrates -ok
+- Seeds - ok
+- Log - ok
+- Paginação-ok
+- SOLID -ok
+- Factory-ok
+- Singleton-ok
+- TDD-ok
+- VIDEO-ok
+
+dotnet ef migrations add Migration5 --context DataContext
+dotnet ef database update --context DataContext
+```
+
+## Video Projeto execultaldo
+
+```sh
+ https://www.youtube.com/watch?v=mjB4KRNpt3g
+
+```
diff --git a/BookManager/Repository/BaseRepository.cs b/BookManager/Repository/BaseRepository.cs
new file mode 100644
index 00000000..1e37ffa4
--- /dev/null
+++ b/BookManager/Repository/BaseRepository.cs
@@ -0,0 +1,35 @@
+
+using BookManager.Data;
+using BookManager.Repository.Interfaces;
+
+namespace BookManager.Repository
+{
+ public class BaseRepository : IBaseRepository
+ {
+ private readonly DataContext _context;
+
+ public BaseRepository(DataContext context)
+ {
+ _context = context;
+ }
+ public void Add(T entity) where T : class
+ {
+ _context.Add(entity);
+ }
+
+ public void Delete(T entity) where T : class
+ {
+ _context.Remove(entity);
+ }
+
+ public async Task SaveChangesAsync()
+ {
+ return await _context.SaveChangesAsync() > 0;
+ }
+
+ public void Update(T entity) where T : class
+ {
+ _context.Update(entity);
+ }
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Repository/BookRepository.cs b/BookManager/Repository/BookRepository.cs
new file mode 100644
index 00000000..e37839a8
--- /dev/null
+++ b/BookManager/Repository/BookRepository.cs
@@ -0,0 +1,99 @@
+using BookManager.Data;
+using BookManager.Model;
+using BookManager.Repository.Interfaces;
+using Microsoft.EntityFrameworkCore;
+
+namespace BookManager.Repository
+{
+ public class BookRepository : BaseRepository, IBookRepository
+ {
+ private readonly DataContext _context;
+ public BookRepository(DataContext context) : base(context)
+ {
+ _context = context;
+ }
+
+ public async Task> GetBooksAsync()
+ {
+ return await _context.Books.OrderBy(b => b.name).Take(1000).ToListAsync();
+ }
+
+ public async Task GetBooksByIdAsync(int id)
+ {
+
+ Book? ret = await _context.Books.Where(x => x.id == id).FirstOrDefaultAsync();
+ if (ret == null)
+ {
+ ret = new Book();
+ }
+ return ret;
+
+ }
+
+ public async Task> GetFilter(int skip, int take, string name)
+ {
+
+ name = string.IsNullOrWhiteSpace(name) ? string.Empty : name.Trim().ToLower();
+
+ if (!string.IsNullOrWhiteSpace(name))
+ {
+ return await _context.Books.Where(
+ x => x.name.Trim().ToLower().Contains(name)
+ ).AsNoTracking().Skip(skip).Take(take).OrderBy(b => b.name).ToListAsync();
+ }
+ else
+ {
+ return await _context.Books.AsNoTracking().Skip(skip).Take(take).OrderBy(b => b.name).ToListAsync();
+ }
+ }
+
+ public int getCountBook(string name)
+ {
+ int count = 0;
+
+ name = string.IsNullOrWhiteSpace(name) ? string.Empty : name.Trim().ToLower();
+
+ if (!string.IsNullOrWhiteSpace(name))
+ {
+ count = _context.Books.Where(
+ x => x.name.Trim().ToLower().Contains(name)
+ ).AsNoTracking().Count();
+ }
+ else
+ {
+ count = _context.Books.Count();
+ }
+ return count;
+ }
+
+
+
+
+
+ public async Task bookCheckExists(Book book)
+ {
+ var ret = await _context.Books.Where(x => x.isnb == book.isnb).ToListAsync();
+ return (ret != null && ret.Any());
+
+ }
+
+
+ public async Task getMaxIdBook()
+ {
+ int maxId = 0;
+ var lst = await _context.Books.OrderByDescending(b => b.id).Take(1).ToListAsync();
+ if (lst != null && lst.Any())
+ {
+ var obj = lst.FirstOrDefault();
+ if (obj != null)
+ {
+ maxId = obj.id;
+ }
+
+ }
+ return maxId;
+
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Repository/CostomLogRepository.cs b/BookManager/Repository/CostomLogRepository.cs
new file mode 100644
index 00000000..a774ae0d
--- /dev/null
+++ b/BookManager/Repository/CostomLogRepository.cs
@@ -0,0 +1,16 @@
+using BookManager.Data;
+using BookManager.Repository.Interfaces;
+
+namespace BookManager.Repository
+{
+ public class CostomLogRepository : BaseRepository, ICostomLogRepository
+ {
+ private readonly DataContext _context;
+ public CostomLogRepository(DataContext context) : base(context)
+ {
+ _context = context;
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Repository/Interfaces/IBaseRepository.cs b/BookManager/Repository/Interfaces/IBaseRepository.cs
new file mode 100644
index 00000000..5a6fc1a5
--- /dev/null
+++ b/BookManager/Repository/Interfaces/IBaseRepository.cs
@@ -0,0 +1,10 @@
+namespace BookManager.Repository.Interfaces
+{
+ public interface IBaseRepository
+ {
+ public void Add(T entity) where T : class;
+ public void Update(T entity) where T : class;
+ public void Delete(T entity) where T : class;
+ Task SaveChangesAsync();
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Repository/Interfaces/IBookRepository.cs b/BookManager/Repository/Interfaces/IBookRepository.cs
new file mode 100644
index 00000000..df9a73e9
--- /dev/null
+++ b/BookManager/Repository/Interfaces/IBookRepository.cs
@@ -0,0 +1,16 @@
+using BookManager.Model;
+
+namespace BookManager.Repository.Interfaces
+{
+ public interface IBookRepository : IBaseRepository
+ {
+ public Task> GetBooksAsync();
+ public Task GetBooksByIdAsync(int id);
+ public Task bookCheckExists(Book book);
+
+ public Task> GetFilter(int skip, int take, string name);
+
+ public Task getMaxIdBook();
+ public int getCountBook(string name);
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Repository/Interfaces/ICostomLogRepository.cs b/BookManager/Repository/Interfaces/ICostomLogRepository.cs
new file mode 100644
index 00000000..a2c6ac70
--- /dev/null
+++ b/BookManager/Repository/Interfaces/ICostomLogRepository.cs
@@ -0,0 +1,8 @@
+
+namespace BookManager.Repository.Interfaces
+{
+ public interface ICostomLogRepository : IBaseRepository
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Repository/Interfaces/IUserRepository.cs b/BookManager/Repository/Interfaces/IUserRepository.cs
new file mode 100644
index 00000000..0f28fcb5
--- /dev/null
+++ b/BookManager/Repository/Interfaces/IUserRepository.cs
@@ -0,0 +1,10 @@
+using BookManager.Model;
+
+namespace BookManager.Repository.Interfaces
+{
+ public interface IUserRepository : IBaseRepository
+ {
+ public Task login(Credential credential);
+ public Task checkUserExists(User user);
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Repository/UserRepository.cs b/BookManager/Repository/UserRepository.cs
new file mode 100644
index 00000000..a39ffe6a
--- /dev/null
+++ b/BookManager/Repository/UserRepository.cs
@@ -0,0 +1,41 @@
+using BookManager.Data;
+using BookManager.Model;
+using BookManager.Repository.Interfaces;
+using Microsoft.EntityFrameworkCore;
+
+
+namespace BookManager.Repository
+{
+ public class UserRepository : BaseRepository, IUserRepository
+ {
+
+ private readonly DataContext _context;
+ public UserRepository(DataContext context) : base(context)
+ {
+ _context = context;
+ }
+
+
+ public async Task login(Credential credential)
+ {
+ var ret = await _context.Users.Where(user => user.email.ToLower().Trim().Equals(credential.email.ToLower().Trim()) &&
+ user.password.Equals(credential.password)).FirstOrDefaultAsync();
+ if (ret != null)
+ {
+ ret.password = string.Empty;
+ return ret;
+ }
+ return new User();
+
+ }
+
+ public async Task checkUserExists(User user)
+ {
+ if (user == null || string.IsNullOrWhiteSpace(user.email)) return false;
+ string email = user.email.Trim().ToLower();
+ var ret = await _context.Users.Where(user => user.email.Equals(email)).ToListAsync();
+ return !(ret == null || !ret.Any());
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Services/CustomLogFactory/CustomLogFactory.cs b/BookManager/Services/CustomLogFactory/CustomLogFactory.cs
new file mode 100644
index 00000000..08582d56
--- /dev/null
+++ b/BookManager/Services/CustomLogFactory/CustomLogFactory.cs
@@ -0,0 +1,26 @@
+
+using BookManager.Services.CustomLogFactory;
+using BookManager.Services.CustomLogFactory.Interface;
+
+namespace BookManager.Services.CustomLog
+{
+ public class Factory
+ {
+ public ICustomLogger FactoryMethod(int tipo)
+ {
+
+ switch (tipo)
+ {
+ case 1:
+ return new CustomLoggerError();
+ //break;
+ case 2:
+ return new CustomLoggerSuccess();
+ //break;
+ default:
+ return new CustomLoggerError();
+ //break;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Services/CustomLogFactory/CustomLogger.cs b/BookManager/Services/CustomLogFactory/CustomLogger.cs
new file mode 100644
index 00000000..bbe7f6bb
--- /dev/null
+++ b/BookManager/Services/CustomLogFactory/CustomLogger.cs
@@ -0,0 +1,14 @@
+
+using BookManager.Services.CustomLog;
+
+namespace BookManager.Services.CustomLogFactory
+{
+ public class CustomLogger
+ {
+ public void logger(string pOperation, string pTrace, int tipo)
+ {
+ var log = new Factory().FactoryMethod(tipo);
+ log.logger(pOperation, pTrace);
+ }
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Services/CustomLogFactory/CustomLoggerError.cs b/BookManager/Services/CustomLogFactory/CustomLoggerError.cs
new file mode 100644
index 00000000..e0f37d0e
--- /dev/null
+++ b/BookManager/Services/CustomLogFactory/CustomLoggerError.cs
@@ -0,0 +1,14 @@
+using BookManager.Data;
+using BookManager.Repository;
+using BookManager.Services.CustomLogFactory.Interface;
+
+namespace BookManager.Services.CustomLogFactory
+{
+ public class CustomLoggerError : ICustomLogger
+ {
+ public void logger(string pOperation, string pTrace)
+ {
+ //Classe e metodo desacoplado
+ }
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Services/CustomLogFactory/CustomLoggerSuccess.cs b/BookManager/Services/CustomLogFactory/CustomLoggerSuccess.cs
new file mode 100644
index 00000000..21a50214
--- /dev/null
+++ b/BookManager/Services/CustomLogFactory/CustomLoggerSuccess.cs
@@ -0,0 +1,13 @@
+
+using BookManager.Services.CustomLogFactory.Interface;
+
+namespace BookManager.Services.CustomLog
+{
+ public class CustomLoggerSuccess : ICustomLogger
+ {
+ public void logger(string pOperation, string pTrace)
+ {
+ //Classe e metodo desacoplado
+ }
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Services/CustomLogFactory/Interface/ICustomLogger.cs b/BookManager/Services/CustomLogFactory/Interface/ICustomLogger.cs
new file mode 100644
index 00000000..d9f10bed
--- /dev/null
+++ b/BookManager/Services/CustomLogFactory/Interface/ICustomLogger.cs
@@ -0,0 +1,11 @@
+
+namespace BookManager.Services.CustomLogFactory.Interface
+{
+ public interface ICustomLogger
+ {
+ public void logger(string pOperation, string pTrace);
+ }
+}
+
+
+
diff --git a/BookManager/Services/Settins.cs b/BookManager/Services/Settins.cs
new file mode 100644
index 00000000..58af3b5d
--- /dev/null
+++ b/BookManager/Services/Settins.cs
@@ -0,0 +1,7 @@
+namespace BookManager.Services
+{
+ public static class Settins
+ {
+ public static string secret = "3NzaC1yc2EAAAADAQABAAABAQCXsM9ycbHV6E6t2";
+ }
+}
\ No newline at end of file
diff --git a/BookManager/Services/TokenService.cs b/BookManager/Services/TokenService.cs
new file mode 100644
index 00000000..951626f2
--- /dev/null
+++ b/BookManager/Services/TokenService.cs
@@ -0,0 +1,99 @@
+using System.Text;
+using BookManager.Model;
+using System.Security.Claims;
+using System.IdentityModel.Tokens.Jwt;
+using Microsoft.IdentityModel.Tokens;
+namespace BookManager.Services;
+
+public class TokenService
+{
+ public Token GenerateToken(User user)
+ {
+ var tokenHandler = new JwtSecurityTokenHandler();
+ var key = Encoding.ASCII.GetBytes(Settins.secret);
+ var token = new Token();
+ token.expires = DateTime.UtcNow.AddHours(8);
+ var tokenDescriptor = new SecurityTokenDescriptor
+ {
+ Subject = this.GetClaims(user),
+ Expires = token.expires,
+ SigningCredentials = new SigningCredentials(
+ new SymmetricSecurityKey(key),
+ SecurityAlgorithms.HmacSha256Signature)
+ };
+ var tokenKey = tokenHandler.CreateToken(tokenDescriptor);
+ token.token = tokenHandler.WriteToken(tokenKey);
+ return token;
+ }
+
+ private ClaimsIdentity GetClaims(User user)
+ {
+ string name = string.IsNullOrWhiteSpace(user.name) ? string.Empty : user.name;
+ string email = string.IsNullOrWhiteSpace(user.email) ? string.Empty : user.email;
+ string role = string.IsNullOrWhiteSpace(user.role) ? string.Empty : user.role;
+
+ var obj = new ClaimsIdentity(new[]
+ {
+ new Claim(ClaimTypes.Name,name),
+ new Claim(ClaimTypes.Email,email),
+ new Claim(ClaimTypes.Role,role)
+ });
+ return obj;
+ }
+
+
+
+
+ public bool IsTokenValid(string token)
+ {
+ if (string.IsNullOrEmpty(token))
+ throw new ArgumentException("Given token is null or empty.");
+ TokenValidationParameters tokenValidationParameters = GetTokenValidationParameters();
+ JwtSecurityTokenHandler jwtSecurityTokenHandler = new JwtSecurityTokenHandler();
+ try
+ {
+ ClaimsPrincipal tokenValid = jwtSecurityTokenHandler.ValidateToken(token, tokenValidationParameters, out SecurityToken validatedToken);
+ return true;
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+ }
+
+ // public IEnumerable GetTokenClaims(string token)
+ // {
+ // if (string.IsNullOrEmpty(token))
+ // throw new ArgumentException("Given token is null or empty.");
+
+ // TokenValidationParameters tokenValidationParameters = GetTokenValidationParameters();
+
+ // JwtSecurityTokenHandler jwtSecurityTokenHandler = new JwtSecurityTokenHandler();
+ // try
+ // {
+ // ClaimsPrincipal tokenValid = jwtSecurityTokenHandler.ValidateToken(token, tokenValidationParameters, out SecurityToken validatedToken);
+ // return tokenValid.Claims;
+ // }
+ // catch (Exception ex)
+ // {
+ // throw ex;
+ // }
+ // }
+
+ private SecurityKey GetSymmetricSecurityKey()
+ {
+ byte[] symmetricKey = Convert.FromBase64String(Settins.secret);
+ return new SymmetricSecurityKey(symmetricKey);
+ }
+
+ private TokenValidationParameters GetTokenValidationParameters()
+ {
+ return new TokenValidationParameters()
+ {
+ ValidateIssuer = false,
+ ValidateAudience = false,
+ IssuerSigningKey = GetSymmetricSecurityKey()
+ };
+ }
+}
+
diff --git a/BookManager/appsettings.Development.json b/BookManager/appsettings.Development.json
new file mode 100644
index 00000000..0c208ae9
--- /dev/null
+++ b/BookManager/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/BookManager/appsettings.json b/BookManager/appsettings.json
new file mode 100644
index 00000000..f3af97e9
--- /dev/null
+++ b/BookManager/appsettings.json
@@ -0,0 +1,15 @@
+{
+ "ConnectionStrings": {
+ "DefaultConnection": "Host=localhost;Port=5432;Pooling=true;Database=db_book_manager;User Id=playfast;Password=playfast01;"
+ },
+ "JwtKey": "ZmVkYWY3ZDg4NjNiNDhlMTk3YjkyODdkNDkyYjcwOGU=",
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft": "Warning",
+ "Microsoft.AspNetCore.HttpLogging": "Information",
+ "Microsoft.Hosting.Lifetime": "Information"
+ }
+ },
+ "AllowedHosts": "*"
+}
diff --git a/Books.postman_collection.json b/Books.postman_collection.json
new file mode 100644
index 00000000..53632c31
--- /dev/null
+++ b/Books.postman_collection.json
@@ -0,0 +1,295 @@
+{
+ "info": {
+ "_postman_id": "7b215260-6446-4bc4-bb18-32f4b9196726",
+ "name": "Books",
+ "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
+ "_exporter_id": "19952004"
+ },
+ "item": [
+ {
+ "name": "01 - AuthSignup",
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{ \r\n \"name\": \"User Test\",\r\n \"email\": \"1241@Gmail.com\",\r\n \"password\": \"ForteLuz@123\",\r\n \"role\": \"ADM\"\r\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "https://localhost:7102/api/Auth/signup",
+ "protocol": "https",
+ "host": [
+ "localhost"
+ ],
+ "port": "7102",
+ "path": [
+ "api",
+ "Auth",
+ "signup"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "02 - AuthLogin",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "exec": [
+ "var jsonData = JSON.parse(responseBody);\r",
+ "//pm.environment.set(\"token_app\",JSON.stringify( jsonData.token));\r",
+ "pm.environment.set(\"token_app\", jsonData.token);\r",
+ "console.log(jsonData.token);\r",
+ "\r",
+ ""
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "request": {
+ "auth": {
+ "type": "noauth"
+ },
+ "method": "POST",
+ "header": [
+ {
+ "key": "",
+ "value": "",
+ "type": "text",
+ "disabled": true
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\r\n \"email\": \"teste@teste.com\",\r\n \"password\": \"123\"\r\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "https://localhost:7102/api/Auth/login",
+ "protocol": "https",
+ "host": [
+ "localhost"
+ ],
+ "port": "7102",
+ "path": [
+ "api",
+ "Auth",
+ "login"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "03 - AddBooks",
+ "request": {
+ "auth": {
+ "type": "noauth"
+ },
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{token_app}}",
+ "type": "text"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\r\n\r\n \"name\": \"Name\",\r\n \"decription\": \"string\",\r\n \"author\": \"string\",\r\n \"idCategory\": 6,\r\n \"isnb\": \"6699\",\r\n \"year\": 2022,\r\n \"idPublisher\": 1,\r\n \"createAt\": \"2022-11-21T14:30:09.501Z\",\r\n \"exemplary\": 1\r\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "https://localhost:7102/api/Books",
+ "protocol": "https",
+ "host": [
+ "localhost"
+ ],
+ "port": "7102",
+ "path": [
+ "api",
+ "Books"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "04 - BookPut",
+ "request": {
+ "method": "PUT",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{token_app}}",
+ "type": "text"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\r\n \"id\": 149,\r\n \"name\": \"novo nome\",\r\n \"decription\": \"Vova Descrição\",\r\n \"isnb\": \"999\",\r\n \"author\": \"Novo Autor\"\r\n \r\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "https://localhost:7102/api/Books",
+ "protocol": "https",
+ "host": [
+ "localhost"
+ ],
+ "port": "7102",
+ "path": [
+ "api",
+ "Books"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "05 - BookDetById",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "https://localhost:7102/api/Books/id/149",
+ "protocol": "https",
+ "host": [
+ "localhost"
+ ],
+ "port": "7102",
+ "path": [
+ "api",
+ "Books",
+ "id",
+ "149"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "06 - BookDelete",
+ "request": {
+ "method": "DELETE",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{token_app}}",
+ "type": "text"
+ }
+ ],
+ "url": {
+ "raw": "https://localhost:7102/api/Books/id/148",
+ "protocol": "https",
+ "host": [
+ "localhost"
+ ],
+ "port": "7102",
+ "path": [
+ "api",
+ "Books",
+ "id",
+ "148"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "07 - Booksload",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{token_app}}",
+ "type": "text"
+ }
+ ],
+ "url": {
+ "raw": "https://localhost:7102/api/Books/load/qtd/100",
+ "protocol": "https",
+ "host": [
+ "localhost"
+ ],
+ "port": "7102",
+ "path": [
+ "api",
+ "Books",
+ "load",
+ "qtd",
+ "100"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "08 - BookGet",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "https://localhost:7102/api/Books",
+ "protocol": "https",
+ "host": [
+ "localhost"
+ ],
+ "port": "7102",
+ "path": [
+ "api",
+ "Books"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "09 - BookGetFilter",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "https://localhost:7102/api/Books/GetFilter/skip/0/take/50/name/name",
+ "protocol": "https",
+ "host": [
+ "localhost"
+ ],
+ "port": "7102",
+ "path": [
+ "api",
+ "Books",
+ "GetFilter",
+ "skip",
+ "0",
+ "take",
+ "50",
+ "name",
+ "name"
+ ]
+ }
+ },
+ "response": []
+ }
+ ]
+}
\ No newline at end of file
diff --git a/CurriculoDantas.pdf b/CurriculoDantas.pdf
new file mode 100644
index 00000000..efcc34c8
Binary files /dev/null and b/CurriculoDantas.pdf differ
diff --git a/Diagrama.md b/Diagrama.md
new file mode 100644
index 00000000..0e2327dd
--- /dev/null
+++ b/Diagrama.md
@@ -0,0 +1,53 @@
+# Diagrama
+
+```mermaid
+classDiagram
+
+Book --> Publisher
+Book --> Category
+stock --> Book
+
+class User {
+ +number id [pk]
+ +string name
+ +string email
+ +string password
+}
+
+class Credential{
+ +string email
+ +string password
+}
+
+
+class Book {
+ +number id [pk]
+ +string title
+ +string description
+ +string autor
+ +string category
+ +string isnb
+ +string yaer
+ +number idPublisher
+}
+
+
+class Publisher {
+ +number id [pk]
+ +string description
+}
+
+class Category {
+ +number id [pk]
+ +string description
+}
+
+class stock {
+ +number idBook [pk]
+ +number quantity
+}
+
+
+
+
+```