Ignore:
Timestamp:
01/06/21 20:48:58 (4 years ago)
Author:
i-ina <76742075+i-ina@…>
Branches:
master
Children:
4a15c9c
Parents:
504c3ef
Message:

register company

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/it/finki/tinki/service/impl/AccountServiceImpl.java

    r504c3ef r721cb87  
    8080        return this.teamRepository.save(t);
    8181    }
     82
     83    public Account registerCompany(String email, String password, String name, String country, String city, String street){
     84        if(email==null || email.isEmpty() || password==null || password.isEmpty() || name==null || name.isEmpty()
     85                || country==null || country.isEmpty() || city==null || city.isEmpty() || street==null || street.isEmpty()){
     86            throw new InvalidArgumentsException();
     87        }
     88
     89        if(this.companyRepository.findByEmail(email).isPresent()){
     90            throw new UserExistsException();
     91        }
     92
     93        Address a = new Address(country, city, street);
     94        this.addressRepository.save(a);
     95        Company c = new Company(email, password, name, AccountType.COMPANY, a);
     96        return this.companyRepository.save(c);
     97    }
    8298}
Note: See TracChangeset for help on using the changeset viewer.