Move Method Body on Repositroy and inject Repository on Service
This commit is contained in:
@@ -17,5 +17,8 @@
|
|||||||
Task DeleteShoppingListAsync(Guid shoppingListId);
|
Task DeleteShoppingListAsync(Guid shoppingListId);
|
||||||
|
|
||||||
Task<Recipe?> GetRecipeByNameAndImageAsync(string recipeName, string imageFileName);
|
Task<Recipe?> GetRecipeByNameAndImageAsync(string recipeName, string imageFileName);
|
||||||
|
|
||||||
|
Task<int> GetShoppingListRecipeCountAsync(Guid shoppingListId);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,5 +167,12 @@
|
|||||||
.Include(r => r.MediaFiles.Where(mf => mf.FileName == imageFileName))
|
.Include(r => r.MediaFiles.Where(mf => mf.FileName == imageFileName))
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<int> GetShoppingListRecipeCountAsync(Guid shoppingListId)
|
||||||
|
{
|
||||||
|
return await _context.RecipeShoppingLists
|
||||||
|
.Where(rsl => rsl.ShoppingList.Id == shoppingListId)
|
||||||
|
.CountAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
using Francesco.Recipes.World.Data;
|
namespace Francesco.Recipes.World.Services.ShoppingList
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Francesco.Recipes.World.Services.ShoppingList
|
|
||||||
{
|
{
|
||||||
|
using Francesco.Recipes.World.Data;
|
||||||
|
using Francesco.Recipes.World.Repositories.ShoppingList;
|
||||||
|
|
||||||
public class ShoppingListService
|
public class ShoppingListService
|
||||||
{
|
{
|
||||||
private readonly FrancescosRecipesWorldDbContext _context;
|
private readonly FrancescosRecipesWorldDbContext _context;
|
||||||
|
private readonly IShoppingListRepository _shoppingListRepository;
|
||||||
|
|
||||||
public ShoppingListService(FrancescosRecipesWorldDbContext context)
|
public ShoppingListService(FrancescosRecipesWorldDbContext context, IShoppingListRepository shoppingListRepository)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
|
_shoppingListRepository = shoppingListRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GetShoppingListRecipeCountAsync(Guid shoppingListId)
|
public async Task<int> GetShoppingListRecipeCountAsync(Guid shoppingListId)
|
||||||
{
|
{
|
||||||
return await _context.RecipeShoppingLists
|
return await _shoppingListRepository.GetShoppingListRecipeCountAsync(shoppingListId);
|
||||||
.Where(rsl => rsl.ShoppingList.Id == shoppingListId)
|
|
||||||
.CountAsync();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user