Skip to content
Draft
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
32 changes: 32 additions & 0 deletions net6_bread_be/Controllers/CountryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using net6_bread_be.Models;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;

namespace net6_bread_be.Controllers
{
Expand Down Expand Up @@ -45,5 +46,36 @@ public async Task<ActionResult<Country>> GetCountryById(int id)
return Ok(country); // Explicitly return an OkObjectResult with the bread item
}

// GET: /Country/{id} <-- This method will replace the method above. I'm just work shopping here.
[HttpGet("/testing/{id}")]
public async Task<IActionResult> GetCountryAndBreads(int id)
{
var country = await _context.Countries.FindAsync(id);

if (country == null)
{
return NotFound();
}

var breads = await _context.Breads.Where(b => b.CountryId == id).ToListAsync();

var result = new
{
Country = new
{
country.CountryId,
country.Name,
country.Description
},
Bread = breads.Select(b => new
{
b.BreadId,
b.Name,
b.Recipe,
b.Description
})
};
return Ok(result);
}
}
}
33 changes: 0 additions & 33 deletions net6_bread_be/Controllers/WeatherForecastController.cs

This file was deleted.

1 change: 1 addition & 0 deletions net6_bread_be/CountryTrackerContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace net6_bread_be
public class CountryTrackerContext : DbContext
{
public DbSet<Country>? Countries { get; set; }
public DbSet<Bread>? Breads { get; set; }

public CountryTrackerContext(DbContextOptions<CountryTrackerContext> options)
: base(options)
Expand Down
13 changes: 0 additions & 13 deletions net6_bread_be/WeatherForecast.cs

This file was deleted.

25 changes: 25 additions & 0 deletions net6_bread_be_tests/net6_bread_be_tests.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 25.0.1706.9
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "net6_bread_be_tests", "net6_bread_be_tests.csproj", "{E4F10C84-808C-4227-B480-DC4C1938F2A2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E4F10C84-808C-4227-B480-DC4C1938F2A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E4F10C84-808C-4227-B480-DC4C1938F2A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4F10C84-808C-4227-B480-DC4C1938F2A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4F10C84-808C-4227-B480-DC4C1938F2A2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6911C9B1-0CBF-446F-B310-1D315AA634B2}
EndGlobalSection
EndGlobal