diff --git a/README.md b/README.md index 15f448a..2dd18d8 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,13 @@ Pizza Shop needs a very simple ordering system with just just 3 tables, Customer - Include yourself as a customer and your favourite Pizza. -## Extension +## Extension (choose at least two) +- Add extra toppings to Pizzas and allow customers to add toppings to their order. Add a new table for Toppings and a new table for OrderToppings. Add any endpoints you think necessary to add toppings. - Assume that Pizzas take 3 minutes to prepare and 12 minutes to cook in the oven. Modify your code so your customers see at what stage their order is and add an endpoint so the delivery drivers app can set the order as Delivered - -## Super Extension (optional) - - The Pizza Shop can only cook 4 pizzas at a time and the delivery driver is allocated 10 minutes to deliver one pizza at a time. Add an estimated delivery time to the Order! - +- Add a new table for DeliveryDrivers and add an endpoint to assign a driver to an order. Add a new endpoint to get all orders for a driver. +- Add the ability for the Pizza shop to sell other products on the Menu. e.g. Burgers, Fries, Drinks. Update any existing code and add any endpoints you think necessary to add products these to an order. ## Tips diff --git a/exercise.pizzashopapi/Controllers/WeatherForecastController.cs b/exercise.pizzashopapi/Controllers/WeatherForecastController.cs deleted file mode 100644 index a4905c4..0000000 --- a/exercise.pizzashopapi/Controllers/WeatherForecastController.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.AspNetCore.Mvc; - -namespace exercise.pizzashopapi.Controllers; - -[ApiController] -[Route("[controller]")] -public class WeatherForecastController : ControllerBase -{ - private static readonly string[] Summaries = new[] - { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; - - private readonly ILogger _logger; - - public WeatherForecastController(ILogger logger) - { - _logger = logger; - } - - [HttpGet(Name = "GetWeatherForecast")] - public IEnumerable Get() - { - return Enumerable.Range(1, 5).Select(index => new WeatherForecast - { - Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), - TemperatureC = Random.Shared.Next(-20, 55), - Summary = Summaries[Random.Shared.Next(Summaries.Length)] - }) - .ToArray(); - } -} diff --git a/exercise.pizzashopapi/Data/Seeder.cs b/exercise.pizzashopapi/Data/Seeder.cs index 99708b4..f87fbef 100644 --- a/exercise.pizzashopapi/Data/Seeder.cs +++ b/exercise.pizzashopapi/Data/Seeder.cs @@ -12,7 +12,7 @@ public async static void SeedPizzaShopApi(this WebApplication app) { db.Add(new Customer() { Name="Nigel" }); db.Add(new Customer() { Name = "Dave" }); - db.SaveChanges(); + await db.SaveChangesAsync(); } if(!db.Pizzas.Any()) { @@ -26,7 +26,7 @@ public async static void SeedPizzaShopApi(this WebApplication app) if(1==1) { - db.SaveChanges(); + await db.SaveChangesAsync(); } } } diff --git a/exercise.pizzashopapi/Program.cs b/exercise.pizzashopapi/Program.cs index 6e3a526..c04a440 100644 --- a/exercise.pizzashopapi/Program.cs +++ b/exercise.pizzashopapi/Program.cs @@ -31,4 +31,5 @@ app.ConfigurePizzaShopApi(); app.SeedPizzaShopApi(); + app.Run(); diff --git a/exercise.pizzashopapi/Repository/IRepository.cs b/exercise.pizzashopapi/Repository/IRepository.cs index 627a84c..b114ea8 100644 --- a/exercise.pizzashopapi/Repository/IRepository.cs +++ b/exercise.pizzashopapi/Repository/IRepository.cs @@ -4,7 +4,7 @@ namespace exercise.pizzashopapi.Repository { public interface IRepository { - IEnumerable GetOrdersByCustomer(); + Task> GetOrdersByCustomer(int id); } diff --git a/exercise.pizzashopapi/Repository/Repository.cs b/exercise.pizzashopapi/Repository/Repository.cs index bf89b16..e109fce 100644 --- a/exercise.pizzashopapi/Repository/Repository.cs +++ b/exercise.pizzashopapi/Repository/Repository.cs @@ -6,9 +6,9 @@ namespace exercise.pizzashopapi.Repository public class Repository : IRepository { private DataContext _db; - public IEnumerable GetOrdersByCustomer(int id) + public Task> GetOrdersByCustomer(int id) { - return _db.ord + throw new NotImplementedException(); } } } diff --git a/exercise.pizzashopapi/WeatherForecast.cs b/exercise.pizzashopapi/WeatherForecast.cs deleted file mode 100644 index 864ca65..0000000 --- a/exercise.pizzashopapi/WeatherForecast.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace exercise.pizzashopapi; - -public class WeatherForecast -{ - public DateOnly Date { get; set; } - - public int TemperatureC { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - - public string? Summary { get; set; } -} diff --git a/exercise.pizzashopapi/exercise.pizzashopapi.csproj b/exercise.pizzashopapi/exercise.pizzashopapi.csproj index d297e56..624203b 100644 --- a/exercise.pizzashopapi/exercise.pizzashopapi.csproj +++ b/exercise.pizzashopapi/exercise.pizzashopapi.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 enable enable