Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. public async updateById(placeId: string, place: string, placeImg?: Express.Multer.File): Promise<IExtendedPlace> {
  2. const existingPlace = await this.retriveById(placeId);
  3. const placeIndex = this.findPlaceIndex(placeId);
  4.  
  5. if(!existingPlace || (placeIndex < 0)) {
  6. return undefined;
  7. }
  8.  
  9. const basicPlace: IBasicPlace = this.toBasicPlace(place);
  10. Object.assign(existingPlace, basicPlace);
  11. if(placeImg){
  12. const imagePath: string = await this.storeImageInDisk(placeId, basicPlace.name, placeImg);
  13. existingPlace.image = imagePath;
  14. }
  15. this.places[placeIndex] = existingPlace;
  16.  
  17. return existingPlace;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement