Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import { IBasicPlace, IExtendedPlace } from "../models/place";
  2.  
  3. import * as uuid from "uuid/v1";
  4.  
  5. export interface IPlaceService {
  6. addPlace(place: IBasicPlace): IExtendedPlace;
  7. }
  8.  
  9. export class PlaceService implements IPlaceService {
  10. private static _instance: PlaceService;
  11. private places: IExtendedPlace[];
  12.  
  13. private constructor() {
  14. this.places = [];
  15. }
  16.  
  17. public static get Instance() {
  18. return this._instance || (this._instance = new this());
  19. }
  20.  
  21. public addPlace(place: IBasicPlace): IExtendedPlace {
  22. place.id = uuid();
  23. if(this.places.push(place) > 0) {
  24. return place;
  25. }
  26.  
  27. return undefined;
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement