Advertisement
nokutu

Untitled

Feb 25th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public async updateElement({tx, ty, tz, rx, ry, rz, name, asset}: SpaceElement, elementOid: string, spaceOid: string, userId: string): Promise<void> {
  2.         const space = await this.spaceRepository.findSpaceByOidAndUserId(spaceOid, userId);
  3.         if (space) {
  4.             const element = await this.spaceRepository.findElementByOidAndSpace(elementOid, spaceOid);
  5.             if (element) {
  6.                 Object.assign(element, {tx, ty, tz, rx, ry, rz, name});
  7.                 if (asset) {
  8.                     element.asset = await this.spaceRepository.findAssetByOid(asset.oid);
  9.                 }
  10.                 return this.spaceRepository.updateElement(element);
  11.             } else {
  12.                 throw new Error('The element does not exist for this space');
  13.             }
  14.         } else {
  15.             throw new Error('The space does not exist for this user');
  16.         }
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement