use of com.salesmanager.core.business.services.catalog.category.CategoryService in project shopizer by shopizer-ecommerce.
the class CategoryFacadeImpl method saveCategory.
@Override
public PersistableCategory saveCategory(MerchantStore store, PersistableCategory category) {
try {
Long categoryId = category.getId();
Category target = Optional.ofNullable(categoryId).filter(merchant -> store != null).filter(id -> id > 0).map(categoryService::getById).orElse(new Category());
Category dbCategory = populateCategory(store, category, target);
saveCategory(store, dbCategory, null);
// set category id
category.setId(dbCategory.getId());
return category;
} catch (ServiceException e) {
throw new ServiceRuntimeException("Error while updating category", e);
}
}
Aggregations