Exemplo n.º 1
0
  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);
  }
Exemplo n.º 2
0
  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);
  }
Exemplo n.º 3
0
 public void deleteAll() {
   categoryRepo.deleteAll();
 }
Exemplo n.º 4
0
 public void delete(Category category) {
   categoryRepo.delete(category);
 }
Exemplo n.º 5
0
 public List<Category> readAll() {
   return categoryRepo.findAll();
 }
Exemplo n.º 6
0
 public Category read(String id) {
   return categoryRepo.findOne(id);
 }