Put one Method to Count all ShoppingListsRecipe
This commit is contained in:
@@ -49,8 +49,6 @@
|
|||||||
<Folder Include="Services\Category\" />
|
<Folder Include="Services\Category\" />
|
||||||
<Folder Include="Services\MediaFile\" />
|
<Folder Include="Services\MediaFile\" />
|
||||||
<Folder Include="Services\Ingredient\" />
|
<Folder Include="Services\Ingredient\" />
|
||||||
<Folder Include="Services\Instruction\" />
|
|
||||||
<Folder Include="Services\ShoppingList\" />
|
|
||||||
<Folder Include="Services\Recipe\" />
|
<Folder Include="Services\Recipe\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Francesco.Recipes.World.Services.ShoppingList
|
||||||
|
{
|
||||||
|
public interface IShoppingListService
|
||||||
|
{
|
||||||
|
Task<int> GetShoppingListRecipeCountAsync(Guid shoppingListId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using Francesco.Recipes.World.Data;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace Francesco.Recipes.World.Services.ShoppingList
|
||||||
|
{
|
||||||
|
public class ShoppingListService
|
||||||
|
{
|
||||||
|
private readonly FrancescosRecipesWorldDbContext _context;
|
||||||
|
|
||||||
|
public ShoppingListService(FrancescosRecipesWorldDbContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> GetShoppingListRecipeCountAsync(Guid shoppingListId)
|
||||||
|
{
|
||||||
|
return await _context.RecipeShoppingLists
|
||||||
|
.Where(rsl => rsl.ShoppingList.Id == shoppingListId)
|
||||||
|
.CountAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user