public async Task <IHttpActionResult> Get(string identifier, OrganisationType organisationType) { var query = new GetOrganisationQuery { OrganisationType = organisationType, Identifier = identifier }; try { var response = await _mediator.SendAsync(query); return(Ok(response.Organisation)); } catch (BadOrganisationIdentifierException e) { return(BadRequest(e.Message)); } catch (OperationNotSupportedForOrganisationTypeException e) { return(BadRequest(e.Message)); } catch (OrganisationNotFoundException) { return(NotFound()); } catch (Exception e) { return(InternalServerError(e)); } }
protected IDisposable SwitchOrgScope(string organisationId) { if (AppContext.CurrentUser.Role != UserRole.SuperUser) { throw new ErrorditeNotSuperUserException(); } var org = GetOrganisationQuery.Invoke(new GetOrganisationRequest() { OrganisationId = organisationId }) .Organisation; return(AppSession.SwitchOrg(org)); }