feat: adding Reading.cs model and Get, GetById and Post method#14
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new “Reading” domain object and basic CRUD-ish API endpoints to persist and retrieve air-quality readings in the AirAware backend.
Changes:
- Introduces
Readingmodel andCreateReadingViewModel. - Adds
ReadingsDbSet toAppDbContext. - Adds
ReadingControllerwithGET /readings,GET /readings/{id}, andPOST /readings.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| AirAware/ViewModels/CreateReadingViewModel.cs | Adds request DTO for creating readings. |
| AirAware/Models/Reading.cs | Introduces EF Core entity for readings, including station relationship and timestamps. |
| AirAware/Data/AppDbContext.cs | Registers Readings set in EF Core context. |
| AirAware/Controllers/ReadingController.cs | Adds REST endpoints to list, fetch by id, and create readings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public DbSet<Station> Stations { get; set; } | ||
| public DbSet<Reading> Readings { get; set; } | ||
|
|
||
| protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => | ||
| optionsBuilder.UseSqlite("DataSource=app.db;Cache=Shared"); |
There was a problem hiding this comment.
This PR adds a new Readings DbSet/entity, but the repo appears to have no EF Core migrations and no startup call to EnsureCreated()/Migrate(). Without schema initialization, hitting the new endpoints will fail at runtime with “no such table: Readings”. Add a migration (and document/apply it) or ensure the database is created/migrated on startup.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
|
@joaoferreira-dev I've opened a new pull request, #15, to work on those changes. Once the pull request is ready, I'll request review from you. |
No description provided.