-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da6dd3c
commit bf52a20
Showing
7 changed files
with
152 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 24 additions & 23 deletions
47
VirtualMind.WebApp/ClientApp/src/app/fetch-data/fetch-data.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,34 @@ | ||
<h1 id="tableLabel">Quotes</h1> | ||
|
||
<div *ngIf="loading"> | ||
<ng-spinner size="5" type="border" color="warning"></ng-spinner> | ||
</div> | ||
|
||
<p> Look the quotation of the day</p> | ||
<div *ngIf="!loading"> | ||
<h1 id="tableLabel">Quotes</h1> | ||
|
||
<p> Look the quotation of the day</p> | ||
|
||
<div *ngIf="dolar"> | ||
<h4>DOLAR (USD)</h4> | ||
<div> | ||
<ul> | ||
<li>Purchase Value: {{ dolar.purchase }}</li> | ||
<li>Sale Value: {{ dolar.sale }}</li> | ||
<li>Last Update: {{ dolar.lastUpdate }}</li> | ||
</ul> | ||
<div *ngIf="dolar"> | ||
<h4>DOLAR (USD)</h4> | ||
<div> | ||
<ul> | ||
<li>Purchase Value: {{ dolar.purchase }}</li> | ||
<li>Sale Value: {{ dolar.sale }}</li> | ||
<li>Last Update: {{ dolar.lastUpdate }}</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
<div *ngIf="real"> | ||
<h4>REAL (BRL)</h4> | ||
<div> | ||
<ul> | ||
<li>Purchase Value: {{ real.purchase }}</li> | ||
<li>Sale Value: {{ real.sale }}</li> | ||
<li>Last Update: {{ real.lastUpdate }}</li> | ||
</ul> | ||
<div *ngIf="real"> | ||
<h4>REAL (BRL)</h4> | ||
<div> | ||
<ul> | ||
<li>Purchase Value: {{ real.purchase }}</li> | ||
<li>Sale Value: {{ real.sale }}</li> | ||
<li>Last Update: {{ real.lastUpdate }}</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<button (click)="getAllQuote()">Update Quotation</button> | ||
|
||
<button (click)="getAllQuote()">Update Quotation</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
VirtualMind.WebApp/ClientApp/src/app/purchase/purchase.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<div class="row"> | ||
<div class="col-6"> | ||
<app-fetch-data></app-fetch-data> | ||
</div> | ||
<div class="col-6"> | ||
<div *ngIf="loading"> | ||
<ng-spinner size="5" type="border" color="warning"></ng-spinner> | ||
</div> | ||
|
||
<div *ngIf="!loading"> | ||
<h4>Make a purchase</h4> | ||
|
||
<form #f="ngForm" (ngSubmit)="onSubmit(f)" novalidate> | ||
<div class="row"> | ||
<div class="col-3"> | ||
<label for="register-user">User ID:</label><br> | ||
<label for="register-amount">Pesos:</label><br> | ||
<label for="register-currency">Pick a currency:</label> | ||
</div> | ||
<div class="col-3"> | ||
<input name="userId" type="number" id="register-user" ngModel required #first="ngModel"> | ||
<input name="amount" type="number" id="register-amount" ngModel required> | ||
<select name="currency" id="register-currency" ngModel required> | ||
<option value="USD">Dólar USD</option> | ||
<option value="BRL">Real BRL</option> | ||
</select> | ||
</div> | ||
</div> | ||
|
||
<button>Submit</button> | ||
</form> | ||
|
||
<div *ngIf="messages && messages.length > 0"> | ||
<div *ngFor="let message of messages"> | ||
<ul> | ||
<li>{{message}}</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
61 changes: 61 additions & 0 deletions
61
VirtualMind.WebApp/ClientApp/src/app/purchase/purchase.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Component, Inject } from '@angular/core'; | ||
import { NgForm } from '@angular/forms'; | ||
import { HttpClient } from '@angular/common/http'; | ||
|
||
@Component({ | ||
selector: 'app-purchase', | ||
templateUrl: './purchase.component.html' | ||
}) | ||
export class PurchaseComponent { | ||
|
||
private messages: Array<string> = []; | ||
private loading: boolean = false; | ||
|
||
constructor(private http: HttpClient, | ||
@Inject('BASE_URL') private baseUrl: string) { | ||
} | ||
|
||
ngOnInit() { | ||
} | ||
|
||
onSubmit(f: NgForm) { | ||
|
||
this.messages = []; | ||
|
||
if (f.valid) { | ||
|
||
this.loading = true; | ||
|
||
const requestObject = { | ||
userId: parseInt(f.value.userId), | ||
requestedAmount: parseFloat(f.value.amount), | ||
currencyType: f.value.currency | ||
}; | ||
|
||
this.http.post(this.baseUrl + 'exchange', requestObject) | ||
.subscribe(result => { | ||
this.messages.push('Wow, Purchase successful! :)'); | ||
f.reset(); | ||
}, error => { | ||
error.error.errors.InvalidOperation.forEach(element => { | ||
this.messages.push(element); | ||
}); | ||
}); | ||
|
||
setTimeout(() => { | ||
this.loading = false; | ||
}, 1000); | ||
} | ||
else { | ||
if (!f.value.userId) { | ||
this.messages.push("User Id is required!"); | ||
} | ||
if (!f.value.amount) { | ||
this.messages.push("Pesos is required!"); | ||
} | ||
if (!f.value.currency) { | ||
this.messages.push("Currency Id is required!"); | ||
} | ||
} | ||
} | ||
} |