public async Task <OrganizationResponseModel> Put(string id, [FromBody] OrganizationUpdateRequestModel model) { var orgIdGuid = new Guid(id); var organization = await _organizationRepository.GetByIdAsync(orgIdGuid); if (organization == null) { throw new NotFoundException(); } var updateBilling = !_globalSettings.SelfHosted && (model.BusinessName != organization.BusinessName || model.BillingEmail != organization.BillingEmail); var hasRequiredPermissions = updateBilling ? await _currentContext.ManageBilling(orgIdGuid) : await _currentContext.OrganizationOwner(orgIdGuid); if (!hasRequiredPermissions) { throw new NotFoundException(); } await _organizationService.UpdateAsync(model.ToOrganization(organization, _globalSettings), updateBilling); return(new OrganizationResponseModel(organization)); }
public async Task <OrganizationResponseModel> Put(string id, [FromBody] OrganizationUpdateRequestModel model) { var userId = _userService.GetProperUserId(User).Value; var organization = await _organizationRepository.GetByIdAsync(new Guid(id), userId); // TODO: Permission checks if (organization == null) { throw new NotFoundException(); } await _organizationRepository.ReplaceAsync(model.ToOrganization(organization)); return(new OrganizationResponseModel(organization)); }
public async Task <OrganizationResponseModel> Put(string id, [FromBody] OrganizationUpdateRequestModel model) { var orgIdGuid = new Guid(id); if (!_currentContext.OrganizationOwner(orgIdGuid)) { throw new NotFoundException(); } var organization = await _organizationRepository.GetByIdAsync(orgIdGuid); if (organization == null) { throw new NotFoundException(); } await _organizationService.UpdateAsync(model.ToOrganization(organization)); return(new OrganizationResponseModel(organization)); }