diff --git a/Program.cs b/Program.cs index 116e6f7..9cfb351 100644 --- a/Program.cs +++ b/Program.cs @@ -1,6 +1,4 @@ using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Storage; -using api_dev_week.src; using api_dev_week.src.Persistence; var builder = WebApplication.CreateBuilder(args); diff --git a/doc/dev-week.md b/doc/dev-week.md index 4689d81..04caf56 100644 --- a/doc/dev-week.md +++ b/doc/dev-week.md @@ -23,4 +23,20 @@ A pasta Models armazenar as classes de modelos. - Post - Enviar dados - Put - Atualizar dados - Patch - Atualizar parcialmente os dados -- Delete - Deletar dados \ No newline at end of file +- Delete - Deletar dados + +### Assuntos para pesquisar. + +## Api + +- DTO (Data transfer Object) - Design Patter +- Injeção de dependências +- Repository Patter + +## Entity Framework +- Migrations +- Os comandos do entity framework + +## Outros Assuntos + +- Criação de Enuns \ No newline at end of file diff --git a/src/Controllers/PersonController.cs b/src/Controllers/PersonController.cs index 0378611..4f1ed80 100644 --- a/src/Controllers/PersonController.cs +++ b/src/Controllers/PersonController.cs @@ -24,16 +24,12 @@ public PersonController(DatabaseContext context) [HttpGet] public ActionResult> Get() { - //Person person = new Person("Arnaldo", 41, "12345678"); - //Contract newContract = new Contract("abc123", 50.56); - //person.Contracts.Add(newContract); - //return person; + var result = _context.Persons.Include(p => p.Contracts).ToList(); if(!result.Any()) return NoContent(); return Ok(result); - } [HttpPost] @@ -49,8 +45,6 @@ public ActionResult Post([FromBody]Person person) return BadRequest(); } - - return Created("created", person); } @@ -70,9 +64,6 @@ public ActionResult Update } ); } - //Console.WriteLine(Id); - //Console.WriteLine(person); - //return "Update " + Id + " Data"; try { diff --git a/src/Models/Contract.cs b/src/Models/Contract.cs index ae7d490..9dff446 100644 --- a/src/Models/Contract.cs +++ b/src/Models/Contract.cs @@ -21,6 +21,5 @@ public Contract(string TokenID, double Valor) public double Valor { get; set; } public bool Paid { get; set; } public int PersonId { get; set; } - } -} +} \ No newline at end of file diff --git a/src/Persistence/DatabaseContext.cs b/src/Persistence/DatabaseContext.cs index 7b14194..b0e4667 100644 --- a/src/Persistence/DatabaseContext.cs +++ b/src/Persistence/DatabaseContext.cs @@ -1,6 +1,5 @@ using Microsoft.EntityFrameworkCore; using api_dev_week.src.Models; -using System.ComponentModel.DataAnnotations.Schema; namespace api_dev_week.src.Persistence { @@ -11,7 +10,6 @@ public DatabaseContext(DbContextOptions { } - public DbSet Persons { get; set; } public DbSet Contracts { get; set; }