Skip to content

Commit

Permalink
Update namespaces, add DishesController and repository
Browse files Browse the repository at this point in the history
Updated namespaces in multiple files from `Restaurants.Domain.Entities` to `Restaurants.Domains.Models`. Reformatted `Address` and `Dish` classes to include braces. Added `DishesController` for handling HTTP requests related to `Dish` entities. Added `DishesRepository` and `IDishesRepository` for managing `Dish` entities. Updated `Resturants.csproj` to include `Microsoft.VisualStudio.Web.CodeGeneration.Design` package.
  • Loading branch information
nahiandev committed Jan 1, 2025
1 parent c5bf90c commit 0754b7c
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 21 deletions.
56 changes: 56 additions & 0 deletions src/Controllers/DishesController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Microsoft.AspNetCore.Mvc;
using Restaurants.DataAccessor;
using Restaurants.Domains.Models;

namespace Resturants.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class DishesController : ControllerBase
{
private readonly ResturantDbContext _context;

public DishesController(ResturantDbContext context)
{
_context = context;
}


[HttpGet]
public async Task<ActionResult<IEnumerable<Dish>>> GetDishes()

Check warning on line 20 in src/Controllers/DishesController.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
throw new NotImplementedException();
}


[HttpGet]
[Route("{id:int}")]
public async Task<ActionResult<Dish>> GetDishById(int id)

Check warning on line 28 in src/Controllers/DishesController.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
throw new NotImplementedException();
}


[HttpPut]
[Route("{id:int}")]
public async Task<IActionResult> UpdateDish(int id, Dish dish)

Check warning on line 36 in src/Controllers/DishesController.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
throw new NotImplementedException();
}


[HttpPost]
public async Task<ActionResult<Dish>> PostDish(Dish dish)

Check warning on line 43 in src/Controllers/DishesController.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
throw new NotImplementedException();
}


[HttpDelete]
[Route("{id:int}")]
public async Task<IActionResult> DeleteDish(int id)

Check warning on line 51 in src/Controllers/DishesController.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
throw new NotImplementedException();
}
}
}
1 change: 0 additions & 1 deletion src/DataAccessor/ResturantDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.EntityFrameworkCore;
using Restaurants.Domain.Entities;
using Restaurants.Domains.Models;

namespace Restaurants.DataAccessor
Expand Down
15 changes: 8 additions & 7 deletions src/Domains/Models/Address.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
namespace Restaurants.Domain.Entities;

public class Address
namespace Restaurants.Domains.Models
{
public string? City { get; set; }
public string? Street { get; set; }
public string? PostalCode { get; set; }
}
public class Address
{
public string? City { get; set; }
public string? Street { get; set; }
public string? PostalCode { get; set; }
}
}
21 changes: 11 additions & 10 deletions src/Domains/Models/Dish.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
namespace Restaurants.Domain.Entities;

public class Dish
namespace Restaurants.Domains.Models
{
public int Id { get; set; }
public string Name { get; set; } = default!;
public string Description { get; set; } = default!;
public decimal Price { get; set; }
public class Dish
{
public int Id { get; set; }
public string Name { get; set; } = default!;
public string Description { get; set; } = default!;
public decimal Price { get; set; }

public int? KiloCalories { get; set; }
public int? KiloCalories { get; set; }

public int RestaurantId { get; set; }
}
public int RestaurantId { get; set; }
}
}
4 changes: 1 addition & 3 deletions src/Domains/Models/Resturant.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Restaurants.Domain.Entities;

namespace Restaurants.Domains.Models
namespace Restaurants.Domains.Models
{
public class Resturant
{
Expand Down
33 changes: 33 additions & 0 deletions src/Repository/Implementations/DishesRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Restaurants.Domains.Models;
using Resturants.Repository.Interfaces;

namespace Resturants.Repository.Implementations
{
public class DishesRepository : IDishesRepository
{
public Task<Dish> AddDishAsync(Dish add_dish)
{
throw new NotImplementedException();
}

public Task<bool> DeleteDishAsync(int id)
{
throw new NotImplementedException();
}

public Task<Dish?> GetDishByIdAsync(int id)
{
throw new NotImplementedException();
}

public Task<List<Dish>> GetDishesAsync()
{
throw new NotImplementedException();
}

public Task<bool> UpdateDishAsync(int id, Dish update_dish)
{
throw new NotImplementedException();
}
}
}
13 changes: 13 additions & 0 deletions src/Repository/Interfaces/IDishesRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Restaurants.Domains.Models;

namespace Resturants.Repository.Interfaces
{
public interface IDishesRepository
{
Task<List<Dish>> GetDishesAsync();
Task<Dish?> GetDishByIdAsync(int id);
Task<Dish> AddDishAsync(Dish add_dish);
Task<bool> DeleteDishAsync(int id);
Task<bool> UpdateDishAsync(int id, Dish update_dish);
}
}
1 change: 1 addition & 0 deletions src/Resturants.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.7" />
<PackageReference Include="Serilog" Version="4.2.0" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
Expand Down

0 comments on commit 0754b7c

Please sign in to comment.