Explorar el Código

modelado de datos para compañias y monedas

robert2206 hace 8 años
padre
commit
5566e334a9

+ 1 - 1
src/app/app.html

@@ -15,7 +15,7 @@
             <div *ngFor="let e of entries">
                 <ion-list-header>{{ e.title }}</ion-list-header>
                 <button ion-item menuClose *ngFor="let p of e.pages" (click)="openPage(p)">
-                    <ion-icon color="primary" name="{{ p.icon }}" style="padding-right: 25px;" item-left></ion-icon>
+                    <ion-icon color="primary" name="{{ p.icon }}" style="padding-right: 25px;"></ion-icon>
                     {{ p.title }}
                 </button>
             </div>

+ 75 - 0
src/models/company.ts

@@ -0,0 +1,75 @@
+import { Currency } from './currency';
+
+export class Company {
+
+    constructor(
+        private _id: number,
+        private _name: string,
+        private _city: string,
+        private _email: string,
+        private _currency: Currency
+    ) {}
+
+    /**
+     *
+     */
+    get id(): number {
+        return this._id;
+    }
+
+    /**
+     *
+     */
+    get name(): string {
+        return this._name;
+    }
+
+    /**
+     *
+     */
+    get city(): string {
+        return this._city;
+    }
+
+    /**
+     *
+     */
+    get email(): string {
+        return this._city;
+    }
+
+    /**
+     *
+     */
+    get currency(): Currency {
+        return this._currency;
+    }
+
+    /**
+     *
+     */
+    set id(_id: number) {
+        this._id = _id;
+    }
+
+    /**
+     *
+     */
+    set name(_name: string) {
+        this._name = _name;
+    }
+
+    /**
+     *
+     */
+    set city(_city: string) {
+        this._city = _city;
+    }
+
+    /**
+     *
+     */
+    set currency(_currency: Currency) {
+        this._currency = _currency;
+    }
+}

+ 50 - 0
src/models/currency.ts

@@ -0,0 +1,50 @@
+export class Currency {
+
+    constructor(
+        private _id: number,
+        private _name: string,
+        private _symbol: string
+    ) {}
+
+    /**
+     *
+     */
+    get id(): number {
+        return this._id;
+    }
+
+    /**
+     *
+     */
+    get name(): string {
+        return this._name;
+    }
+
+    /**
+     *
+     */
+    get symbol(): string {
+        return this._symbol;
+    }
+
+    /**
+     *
+     */
+    set id(_id: number) {
+        this._id = _id;
+    }
+
+    /**
+     *
+     */
+    set name(_name: string) {
+        this._name = _name;
+    }
+
+    /**
+     *
+     */
+    set symbol(_symbol: string) {
+        this._symbol = _symbol;
+    }
+}

+ 24 - 9
src/models/product.ts

@@ -3,7 +3,8 @@ export class Product {
     constructor(
         private _id: number,
         private _name: string,
-        private _displayName: string
+        private _displayName: string,
+        private _price: number
     ) {}
 
     /**
@@ -16,29 +17,36 @@ export class Product {
     /**
      *
      */
-    set id(_id: number) {
-        this._id = _id;
+    get name(): string {
+        return this._name;
     }
 
     /**
      *
      */
-    get name(): string {
-        return this._name;
+    get displayName(): string {
+        return this._displayName;
     }
 
     /**
      *
      */
-    set name(_name: string) {
-        this._name = _name;
+    get price(): number {
+        return this._price;
     }
 
     /**
      *
      */
-    get displayName(): string {
-        return this._displayName;
+    set id(_id: number) {
+        this._id = _id;
+    }
+
+    /**
+     *
+     */
+    set name(_name: string) {
+        this._name = _name;
     }
 
     /**
@@ -47,4 +55,11 @@ export class Product {
     set displayName(_displayName: string) {
         this._displayName = _displayName;
     }
+
+    /**
+     *
+     */
+    set price(_price: number) {
+        this._price = _price;
+    }
 }

+ 4 - 0
src/pages/product-list/product-list.html

@@ -33,6 +33,10 @@
                 <img src="./assets/images/no_product.png" />
             </ion-avatar>
             <h2>{{ p.name }}</h2>
+            <p>
+                <strong>Precio:</strong>
+                {{ p.price }}
+            </p>
         </ion-item>
         <ion-row>
             <ion-col>

+ 1 - 1
src/pages/product-list/product-list.ts

@@ -18,7 +18,7 @@ export class ProductListPage extends DefaultListable<Product> {
     init(): void {
 
         for (let i = 0; i < 100; i++) {
-            this.add(new Product(i + 1, 'Product' + (i + 1), ''));
+            this.add(new Product(i + 1, 'Product' + (i + 1), '', i * 200));
         }
     }