Fix createOrganization to return all fields

Signed-off-by: trivernis <trivernis@protonmail.com>
develop
trivernis 4 years ago
parent 1906d8e6e9
commit b49c990149
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -25,6 +25,7 @@ import { LendingStation } from '../../model/LendingStation';
import { TimeFrame } from '../../model/TimeFrame';
import { ActionLogger, genDateRange, DBUtils, LockUtils } from './utils';
import { ResourceLockedError } from '../../errors/ResourceLockedError';
import { NotFoundError } from '../../errors/NotFoundError';
export class LendingStationAPI extends DataSource {
connection : Connection
@ -247,7 +248,7 @@ export class LendingStationAPI extends DataSource {
.set({ ...timeFrame })
.where('id = :id', { id: timeFrame.id })
.execute()
.then(value => { if (value.affected !== 1) { throw new UserInputError('ID not found'); } });
.then(value => { if (value.affected !== 1) { throw new NotFoundError('TimeFrame', 'id', timeFrame.id); } });
});
!keepLock && await this.unlockTimeFrame(timeFrame.id, userId);
return this.timeFrameById(timeFrame.id);

@ -179,15 +179,17 @@ export class ProviderAPI extends DataSource {
}
async createOrganisation (organisation: any) {
let inserts: any = null;
let createdOrganisation: any = null;
await this.connection.transaction(async (entityManager: EntityManager) => {
inserts = await entityManager.getRepository(Organisation)
const result = await entityManager.getRepository(Organisation)
.createQueryBuilder('o')
.insert()
.values([organisation])
.execute();
createdOrganisation = await entityManager.getRepository(Organisation).findOne(result.identifiers[0].id);
});
return inserts.generatedMaps[0];
return createdOrganisation;
}
async lockOrganisation (id: number, userId: number) {

@ -840,7 +840,7 @@ export default gql`
address: AddressCreateInput!
name: String!
"registration number of association"
associationNo: String!
associationNo: String
"If Club, at what court registered"
registeredAt: String
contactInformationId: ID

Loading…
Cancel
Save