public async Task <OrganizationResponseModel> PostLicense(OrganizationCreateLicenseRequestModel model) { var user = await _userService.GetUserByPrincipalAsync(User); if (user == null) { throw new UnauthorizedAccessException(); } var license = await ApiHelpers.ReadJsonFileFromBody <OrganizationLicense>(HttpContext, model.License); if (license == null) { throw new BadRequestException("Invalid license"); } var policies = await _policyRepository.GetManyByUserIdAsync(user.Id); if (policies.Any(policy => policy.Type == PolicyType.SingleOrg)) { throw new Exception("You may not create an organization. You belong to an organization " + "which has a policy that prohibits you from being a member of any other organization."); } var result = await _organizationService.SignUpAsync(license, user, model.Key, model.CollectionName); return(new OrganizationResponseModel(result.Item1)); }
public async Task <OrganizationResponseModel> PostLicense(OrganizationCreateLicenseRequestModel model) { var user = await _userService.GetUserByPrincipalAsync(User); if (user == null) { throw new UnauthorizedAccessException(); } var license = await ApiHelpers.ReadJsonFileFromBody <OrganizationLicense>(HttpContext, model.License); if (license == null) { throw new BadRequestException("Invalid license"); } var result = await _organizationService.SignUpAsync(license, user, model.Key, model.CollectionName); return(new OrganizationResponseModel(result.Item1)); }