public void create(Category category) throws Exception { Category categoryDoc = categoryRepo.findByIdOrName(category.getId(), category.getName()); if (categoryDoc != null) { throw new Exception("category exists"); } categoryRepo.save(category); }
public void update(Category category) throws Exception { Category categoryDoc = categoryRepo.findByIdOrName(category.getId(), category.getName()); if (categoryDoc == null) { throw new Exception("can't found category"); } category.setId(categoryDoc.getId()); category.setRecipes(categoryDoc.getRecipes()); categoryRepo.save(category); }
public void deleteAll() { categoryRepo.deleteAll(); }
public void delete(Category category) { categoryRepo.delete(category); }
public List<Category> readAll() { return categoryRepo.findAll(); }
public Category read(String id) { return categoryRepo.findOne(id); }