package com.example.rentACar.business.concretes; import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.example.rentACar.business.abstracts.BrandService; import com.example.rentACar.business.requests.CreateBrandRequest; import com.example.rentACar.business.responses.GetAllBrandsResponse; import com.example.rentACar.dataAccess.abstracts.BrandRepository; import com.example.rentACar.entities.concretes.Brand; @Service //bu sınıf bir business nesnesidir public class BrandManager implements BrandService { private BrandRepository brandRepository ; @Autowired public BrandManager(BrandRepository brandRepository) { super(); this.brandRepository = brandRepository; } @Override public List getAll() { List brands = brandRepository.findAll(); List brandsResponse = new ArrayList(); for (Brand brand : brands) { GetAllBrandsResponse responseItem = new GetAllBrandsResponse(); responseItem.setId(brand.getId()); responseItem.setName(brand.getName()); brandsResponse.add(responseItem); } return brandsResponse; } @Override public void add(CreateBrandRequest createBrandRequest) { Brand brand = new Brand(); brand.setName(createBrandRequest.getName()); this.brandRepository.save(brand); } }