Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
18 changes: 17 additions & 1 deletion doc/dev-week.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- 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
11 changes: 1 addition & 10 deletions src/Controllers/PersonController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@ public PersonController(DatabaseContext context)
[HttpGet]
public ActionResult<List <Person>> 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]
Expand All @@ -49,8 +45,6 @@ public ActionResult<Person> Post([FromBody]Person person)
return BadRequest();
}



return Created("created", person);
}

Expand All @@ -70,9 +64,6 @@ public ActionResult<Object> Update
}
);
}
//Console.WriteLine(Id);
//Console.WriteLine(person);
//return "Update " + Id + " Data";

try
{
Expand Down
3 changes: 1 addition & 2 deletions src/Models/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

}
}
}
2 changes: 0 additions & 2 deletions src/Persistence/DatabaseContext.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.EntityFrameworkCore;
using api_dev_week.src.Models;
using System.ComponentModel.DataAnnotations.Schema;

namespace api_dev_week.src.Persistence
{
Expand All @@ -11,7 +10,6 @@ public DatabaseContext(DbContextOptions
{
}


public DbSet<Person> Persons { get; set; }
public DbSet<Contract> Contracts { get; set; }

Expand Down