public Operation <CategoryModel> DeleteCategoryItem(long id) { return(Operation.Create(() => { var query = _repo.Category.FirstOrDefault(c => c.CategoryId == id); // check if the category is tied to a product already ... if (query != null) { _repo.Remove <Category>(query); _repo.SaveChanges(); _logger.LogInformation($"Category is deleted has been set to true with Id= {id}"); } return _mapper.Map <Category, CategoryModel>(query); })); }