Package nl.oneday.data.domain.items

Examples of nl.oneday.data.domain.items.Category



  @RequestMapping(value = Paths.CATEGORY_ADD)
  public String addCategory(HttpServletRequest request, HttpServletResponse response, Model model) {

    Category category = new Category();
    category.setName(request.getParameter("categoryName"));

    if (request.getParameter("categoryName") != null && !request.getParameter("categoryName").isEmpty()) {
      boolean success = categoryService.createCategory(category);
      if (success) {
        LOG.info("category om toegevoegd met naam:" + request.getParameter("name"));
View Full Code Here


    }
  }


  public Item createItem(String name, String price, String description, Long categoryId) {
    Category category = categoryService.findCategoryById(categoryId);
    Item item = new Item();
    item.setName(name);
    item.setCategory(category);
    try {
      item.setPrice(Float.parseFloat(price));
View Full Code Here

  @Autowired
  private CategoryRepository categoryRepository;


  public boolean categoryExists(Long id) {
    Category category = categoryRepository.findById(id);
    if (category != null) return true;
    return false;
  }
View Full Code Here

    return false;
  }


  public boolean deleteCategory(Long id) {
    Category category = null;
    if (categoryExists(id)) {
      try {
        category = categoryRepository.findById(id);
        categoryRepository.delete(category.getId());
        categoryRepository.flush();

        if (categoryRepository.findById(id) == null) {

          LOG.info("Category verwijderd met id: " + id);
View Full Code Here

  }


  public boolean createCategory(Category category) {

    Category savedCategory = null;
    try {
      savedCategory = categoryRepository.saveAndFlush(category);
    }
    catch (Exception ex) {
      LOG.error("Category could not be saved due to an error");
    }

    if (savedCategory != null && savedCategory.getId() != null) {
      LOG.info("nieuwe Category aangemaakt " + savedCategory.getId() + "/" + category.getName() + "/" + category.getName());
      return true;
    }
    else {
      LOG.error("category niet aangemaakt!");
      return false;
View Full Code Here

TOP

Related Classes of nl.oneday.data.domain.items.Category

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.