I'm having a problem on what is the best approach to design my service layer and use them in my controller. Here is my concern.
Currently I'm using this to delete categories
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Delete(List<Guid> ids)
{
if(ids == null || ids.Count == 0)
return RedirectToAction("List");
_categoryService.DeleteCategories(_categoryService.GetCategoryByIds(ids));
_categoryService.SaveChanges();
return RedirectToAction("List");
}
my concern is should I just pass ids to DeleteCategories
then call the GetCategoryByIds
inside the DeleteCategories
. And If I'm only going to delete 1 Category, is it better to add another method like DeleteCategory
then in the controller check the length of the ids and if it is only 1, use DeleteCategory
instead,