Ignore:
Timestamp:
03/13/23 23:30:41 (20 months ago)
Author:
Gjoko Kostadinov <gjoko.kostadinov@…>
Branches:
master
Children:
8bcd64c
Parents:
46fd0c7
Message:

Add admin functionality for activating or deactivating companies

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/edu/gjoko/schedlr/services/BusinessService.java

    r46fd0c7 r9050790  
    22
    33import edu.gjoko.schedlr.entity.Business;
    4 import edu.gjoko.schedlr.entity.BusinessStatus;
    54import edu.gjoko.schedlr.entity.ServiceType;
    65import edu.gjoko.schedlr.entity.StakeholderType;
     
    1110
    1211import java.util.List;
    13 import java.util.stream.Collectors;
    1412
    1513import static edu.gjoko.schedlr.entity.BusinessStatus.ACTIVE;
     
    3230    public void saveNewServiceTypes(Business business) {
    3331        business.getServices()
    34             .stream()
    35             .forEach(service -> {
    36                 if(service.getServiceType().getId() == null) {
    37                     ServiceType serviceType = service.getServiceType();
    38                     serviceType.setBusinessType(business.getBusinessType());
    39                     service.setServiceType(serviceTypeRepository.save(serviceType));
    40                 }
    41             });
     32                .stream()
     33                .forEach(service -> {
     34                    if (service.getServiceType().getId() == null) {
     35                        ServiceType serviceType = service.getServiceType();
     36                        serviceType.setBusinessType(business.getBusinessType());
     37                        service.setServiceType(serviceTypeRepository.save(serviceType));
     38                    }
     39                });
    4240    }
    4341
    44     public List<Business> getNewBusiness() {
    45         return businessRepository.findBusinessesByBusinessStatus(NEW);
     42    public List<Business> findAll() {
     43        return businessRepository.findAll();
    4644    }
    4745
    48     public void activateBusinesses(List<Business> businessList) {
     46    public void updateBusinesses(List<Business> businessList) {
    4947        businessList
    5048                .stream()
    5149                .forEach(business -> {
    52                     business.setBusinessStatus(ACTIVE);
    5350                    businessRepository.save(business);
    5451                });
Note: See TracChangeset for help on using the changeset viewer.