Browse Source

Display marketing campaign details SPA

pull/223/head
Ramón Tomás 7 years ago
parent
commit
249c7a5105
6 changed files with 95 additions and 1 deletions
  1. +1
    -0
      src/Web/WebSPA/AppSettings.cs
  2. +1
    -0
      src/Web/WebSPA/Client/modules/campaign/campaign.module.ts
  3. +89
    -0
      src/Web/WebSPA/Client/modules/campaign/campaign.service.ts
  4. +2
    -1
      src/Web/WebSPA/Client/modules/shared/models/configuration.model.ts
  5. +1
    -0
      src/Web/WebSPA/Client/modules/shared/services/configuration.service.ts
  6. +1
    -0
      src/Web/WebSPA/appsettings.json

+ 1
- 0
src/Web/WebSPA/AppSettings.cs View File

@ -12,5 +12,6 @@ namespace eShopOnContainers.WebSPA
public string OrderingUrl { get; set; } public string OrderingUrl { get; set; }
public string IdentityUrl { get; set; } public string IdentityUrl { get; set; }
public string BasketUrl { get; set; } public string BasketUrl { get; set; }
public string MarketingUrl { get; set; }
} }
} }

+ 1
- 0
src/Web/WebSPA/Client/modules/campaign/campaign.module.ts View File

@ -0,0 +1 @@


+ 89
- 0
src/Web/WebSPA/Client/modules/campaign/campaign.service.ts View File

@ -0,0 +1,89 @@
import { Injectable } from '@angular/core';
import { Response } from '@angular/http';
import { DataService } from '../shared/services/data.service';
import { IOrder } from '../shared/models/order.model';
import { IOrderItem } from '../shared/models/orderItem.model';
import { IOrderDetail } from "../shared/models/order-detail.model";
import { SecurityService } from '../shared/services/security.service';
import { ConfigurationService } from '../shared/services/configuration.service';
import 'rxjs/Rx';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/throw';
import { Observer } from 'rxjs/Observer';
import 'rxjs/add/operator/map';
@Injectable()
export class CampaignService {
private marketingUrl: string = '';
constructor(private service: DataService, private identityService: SecurityService, private configurationService: ConfigurationService) {
if (this.configurationService.isReady)
this.marketingUrl = this.configurationService.serverSettings.marketingUrl;
else
this.configurationService.settingsLoaded$.subscribe(x => this.marketingUrl = this.configurationService.serverSettings.marketingUrl);
}
getOrders(): Observable<IOrder[]> {
let url = this.marketingUrl + '/api/v1/campaigns/';
return this.service.get(url).map((response: Response) => {
return response.json();
});
}
getOrder(id: number): Observable<IOrderDetail> {
let url = this.marketingUrl + '/api/v1/campaigns/' + id;
return this.service.get(url).map((response: Response) => {
return response.json();
});
}
mapOrderAndIdentityInfoNewOrder(): IOrder {
let order = <IOrder>{};
let basket = this.basketService.basket;
let identityInfo = this.identityService.UserData;
console.log(basket);
console.log(identityInfo);
// Identity data mapping:
order.street = identityInfo.address_street;
order.city = identityInfo.address_city;
order.country = identityInfo.address_country;
order.state = identityInfo.address_state;
order.zipcode = identityInfo.address_zip_code;
order.cardexpiration = identityInfo.card_expiration;
order.cardnumber = identityInfo.card_number;
order.cardsecuritynumber = identityInfo.card_security_number;
order.cardtypeid = identityInfo.card_type;
order.cardholdername = identityInfo.card_holder;
order.total = 0;
order.expiration = identityInfo.card_expiration;
// basket data mapping:
order.orderItems = new Array<IOrderItem>();
basket.items.forEach(x => {
let item: IOrderItem = <IOrderItem>{};
item.pictureurl = x.pictureUrl;
item.productId = +x.productId;
item.productname = x.productName;
item.unitprice = x.unitPrice;
item.units = x.quantity;
order.total += (item.unitprice * item.units);
order.orderItems.push(item);
});
order.buyer = basket.buyerId;
return order;
}
}

+ 2
- 1
src/Web/WebSPA/Client/modules/shared/models/configuration.model.ts View File

@ -2,5 +2,6 @@ export interface IConfiguration {
catalogUrl: string, catalogUrl: string,
orderingUrl: string, orderingUrl: string,
identityUrl: string, identityUrl: string,
basketUrl: string
basketUrl: string,
marketingUrl: string
} }

+ 1
- 0
src/Web/WebSPA/Client/modules/shared/services/configuration.service.ts View File

@ -32,6 +32,7 @@ export class ConfigurationService {
this.storageService.store('catalogUrl', this.serverSettings.catalogUrl); this.storageService.store('catalogUrl', this.serverSettings.catalogUrl);
this.storageService.store('identityUrl', this.serverSettings.identityUrl); this.storageService.store('identityUrl', this.serverSettings.identityUrl);
this.storageService.store('orderingUrl', this.serverSettings.orderingUrl); this.storageService.store('orderingUrl', this.serverSettings.orderingUrl);
this.storageService.store('marketingUrl', this.serverSettings.marketingUrl);
this.isReady = true; this.isReady = true;
this.settingsLoadedSource.next(); this.settingsLoadedSource.next();
}); });


+ 1
- 0
src/Web/WebSPA/appsettings.json View File

@ -3,6 +3,7 @@
"OrderingUrl": "http://localhost:5102", "OrderingUrl": "http://localhost:5102",
"BasketUrl": "http://localhost:5103", "BasketUrl": "http://localhost:5103",
"IdentityUrl": "http://localhost:5105", "IdentityUrl": "http://localhost:5105",
"MarketingUrl": "http://localhost:5110",
"CallBackUrl": "http://localhost:5104/", "CallBackUrl": "http://localhost:5104/",
"IsClusterEnv": "False", "IsClusterEnv": "False",
"Logging": { "Logging": {


Loading…
Cancel
Save