Skip to content

Commit 249c7a5

Browse files
committed
Display marketing campaign details SPA
1 parent ff790af commit 249c7a5

6 files changed

Lines changed: 95 additions & 1 deletion

File tree

src/Web/WebSPA/AppSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ public class AppSettings
1212
public string OrderingUrl { get; set; }
1313
public string IdentityUrl { get; set; }
1414
public string BasketUrl { get; set; }
15+
public string MarketingUrl { get; set; }
1516
}
1617
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import { Injectable } from '@angular/core';
2+
import { Response } from '@angular/http';
3+
4+
import { DataService } from '../shared/services/data.service';
5+
import { IOrder } from '../shared/models/order.model';
6+
import { IOrderItem } from '../shared/models/orderItem.model';
7+
import { IOrderDetail } from "../shared/models/order-detail.model";
8+
import { SecurityService } from '../shared/services/security.service';
9+
import { ConfigurationService } from '../shared/services/configuration.service';
10+
11+
import 'rxjs/Rx';
12+
import { Observable } from 'rxjs/Observable';
13+
import 'rxjs/add/observable/throw';
14+
import { Observer } from 'rxjs/Observer';
15+
import 'rxjs/add/operator/map';
16+
17+
18+
@Injectable()
19+
export class CampaignService {
20+
private marketingUrl: string = '';
21+
22+
constructor(private service: DataService, private identityService: SecurityService, private configurationService: ConfigurationService) {
23+
if (this.configurationService.isReady)
24+
this.marketingUrl = this.configurationService.serverSettings.marketingUrl;
25+
else
26+
this.configurationService.settingsLoaded$.subscribe(x => this.marketingUrl = this.configurationService.serverSettings.marketingUrl);
27+
28+
}
29+
30+
getOrders(): Observable<IOrder[]> {
31+
let url = this.marketingUrl + '/api/v1/campaigns/';
32+
33+
return this.service.get(url).map((response: Response) => {
34+
return response.json();
35+
});
36+
}
37+
38+
getOrder(id: number): Observable<IOrderDetail> {
39+
let url = this.marketingUrl + '/api/v1/campaigns/' + id;
40+
41+
return this.service.get(url).map((response: Response) => {
42+
return response.json();
43+
});
44+
}
45+
46+
mapOrderAndIdentityInfoNewOrder(): IOrder {
47+
let order = <IOrder>{};
48+
let basket = this.basketService.basket;
49+
let identityInfo = this.identityService.UserData;
50+
51+
console.log(basket);
52+
console.log(identityInfo);
53+
54+
// Identity data mapping:
55+
order.street = identityInfo.address_street;
56+
order.city = identityInfo.address_city;
57+
order.country = identityInfo.address_country;
58+
order.state = identityInfo.address_state;
59+
order.zipcode = identityInfo.address_zip_code;
60+
order.cardexpiration = identityInfo.card_expiration;
61+
order.cardnumber = identityInfo.card_number;
62+
order.cardsecuritynumber = identityInfo.card_security_number;
63+
order.cardtypeid = identityInfo.card_type;
64+
order.cardholdername = identityInfo.card_holder;
65+
order.total = 0;
66+
order.expiration = identityInfo.card_expiration;
67+
68+
// basket data mapping:
69+
order.orderItems = new Array<IOrderItem>();
70+
basket.items.forEach(x => {
71+
let item: IOrderItem = <IOrderItem>{};
72+
item.pictureurl = x.pictureUrl;
73+
item.productId = +x.productId;
74+
item.productname = x.productName;
75+
item.unitprice = x.unitPrice;
76+
item.units = x.quantity;
77+
78+
order.total += (item.unitprice * item.units);
79+
80+
order.orderItems.push(item);
81+
});
82+
83+
order.buyer = basket.buyerId;
84+
85+
return order;
86+
}
87+
88+
}
89+

src/Web/WebSPA/Client/modules/shared/models/configuration.model.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ export interface IConfiguration {
22
catalogUrl: string,
33
orderingUrl: string,
44
identityUrl: string,
5-
basketUrl: string
5+
basketUrl: string,
6+
marketingUrl: string
67
}

src/Web/WebSPA/Client/modules/shared/services/configuration.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export class ConfigurationService {
3232
this.storageService.store('catalogUrl', this.serverSettings.catalogUrl);
3333
this.storageService.store('identityUrl', this.serverSettings.identityUrl);
3434
this.storageService.store('orderingUrl', this.serverSettings.orderingUrl);
35+
this.storageService.store('marketingUrl', this.serverSettings.marketingUrl);
3536
this.isReady = true;
3637
this.settingsLoadedSource.next();
3738
});

src/Web/WebSPA/appsettings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"OrderingUrl": "http://localhost:5102",
44
"BasketUrl": "http://localhost:5103",
55
"IdentityUrl": "http://localhost:5105",
6+
"MarketingUrl": "http://localhost:5110",
67
"CallBackUrl": "http://localhost:5104/",
78
"IsClusterEnv": "False",
89
"Logging": {

0 commit comments

Comments
 (0)