Exemple #1
0
        public async Task <Employer> Register(Employer user, string password)
        {
            var company = await _companiesRepository.GetByIdAsync(user.CompanyId);

            if (company == null)
            {
                throw new EntityNotFoundException("Such company doesn't exist");
            }
            if (await HasEntityAsync(user))
            {
                throw new UserFoundException("This user already exists");
            }
            PasswordHasher <Employer, Guid> .CreateHashedPassword(password, out var hashedPass, out var saltPass);

            user.HashedPassword = hashedPass;
            user.SaltPassword   = saltPass;
            return(await CreateAsync(user));
        }
        public async Task <Company> DeleteAsync(Guid id)
        {
            var getEntity = await _repository.GetByIdAsync <Company>(id);

            return(await _repository.DeleteAsync(getEntity));
        }