Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7098a9c

Browse files
customerorder added
1 parent cc3d97f commit 7098a9c

File tree

6 files changed

+59
-2
lines changed

6 files changed

+59
-2
lines changed

‎src/AspnetRun.Web/src/app/views/customer/customer-list/customer-grid/customer-grid.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<td>{{ customer.city | trim }}</td>
2626
<td>{{ customer.state.name }}</td>
2727
<td>{{ customer.orderTotal | currency:'USD':'symbol' }}</td>
28-
<td><a [routerLink]="['/customer',customer.id,'orders']">View Orders</a></td>
28+
<td><a [routerLink]="['/customer/customer-order',customer.id]">View Orders</a></td>
2929
</tr>
3030
<tr *ngIf="!customers.length">
3131
<td>&nbsp;</td>

‎src/AspnetRun.Web/src/app/views/customer/customer-order/customer-order.component.css

Whitespace-only changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<div class="container">
2+
<div class="row" *ngIf="customer && customer.orders">
3+
<h4>Orders for {{ customer.firstName | capitalize }} {{ customer.lastName | capitalize }}</h4>
4+
<br />
5+
<table class="table table-striped table-hover orders-table">
6+
<tr *ngFor="let order of customer.orders;trackBy:ordersTrackBy">
7+
<td>{{ order.productName }}</td>
8+
<td class="text-right">{{ order.itemCost | currency:'USD':'symbol' }}</td>
9+
</tr>
10+
<tr class="summary-border">
11+
<td>&nbsp;</td>
12+
<td class="text-right">{{ customer.orderTotal | currency:'USD':'symbol' }}</td>
13+
</tr>
14+
</table>
15+
</div>
16+
<div *ngIf="customer && !customer.orders" class="row">
17+
No orders found
18+
</div>
19+
<div *ngIf="!customer" class="row">
20+
No customer found
21+
</div>
22+
</div>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { IOrder, ICustomer } from 'src/app/shared/interfaces';
3+
import { CustomerDataService } from 'src/app/core/services/customer-data.services';
4+
import { ActivatedRoute, Params } from '@angular/router';
5+
6+
@Component({
7+
selector: 'app-customer-order',
8+
templateUrl: './customer-order.component.html',
9+
styleUrls: ['./customer-order.component.css']
10+
})
11+
export class CustomerOrderComponent implements OnInit {
12+
13+
orders: IOrder[] = [];
14+
customer: ICustomer;
15+
16+
constructor(private route: ActivatedRoute, private dataService: CustomerDataService) { }
17+
18+
ngOnInit() {
19+
this.route.params.subscribe((params: Params) => {
20+
const id = +params['id'];
21+
this.dataService.getCustomerById(id).subscribe((customer: ICustomer) => {
22+
this.customer = customer;
23+
});
24+
});
25+
}
26+
27+
ordersTrackBy(index: number, orderItem: any) {
28+
return index;
29+
}
30+
31+
}

‎src/AspnetRun.Web/src/app/views/customer/customer-routing.module.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Routes, RouterModule } from '@angular/router';
44
import { CustomerListComponent } from './customer-list/customer-list.component';
55
import { CustomerDetailComponent } from './customer-detail/customer-detail.component';
66
import { CustomerEditComponent } from './customer-edit/customer-edit.component';
7+
import { CustomerOrderComponent } from './customer-order/customer-order.component';
78

89
const routes: Routes = [
910
{
@@ -15,6 +16,8 @@ const routes: Routes = [
1516
{ path: 'customer-detail/:id', component: CustomerDetailComponent, data: { title: 'Detail' } },
1617
{ path: 'customer-edit', component: CustomerEditComponent, data: { title: 'New' } },
1718
{ path: 'customer-edit/:id', component: CustomerEditComponent, data: { title: 'Edit' } },
19+
{ path: 'customer-order', component: CustomerOrderComponent, data: { title: 'New' } },
20+
{ path: 'customer-order/:id', component: CustomerOrderComponent, data: { title: 'Edit' } },
1821
]
1922
}
2023
];

‎src/AspnetRun.Web/src/app/views/customer/customer.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import { SharedModule } from 'src/app/shared/shared.module';
44
import { CustomerRoutingModule } from './customer-routing.module';
55
import { FilterTextboxComponent } from './customer-list/filter-textbox/filter-textbox.component';
66
import { CustomerGridComponent } from './customer-list/customer-grid/customer-grid.component';
7+
import { CustomerOrderComponent } from './customer-order/customer-order.component';
78

89
@NgModule({
910
imports: [
1011
CustomerRoutingModule,
1112
SharedModule,
1213
],
13-
declarations: [CustomerRoutingModule.components, FilterTextboxComponent, CustomerGridComponent]
14+
declarations: [CustomerRoutingModule.components, FilterTextboxComponent, CustomerGridComponent,CustomerOrderComponent]
1415
})
1516
export class CustomerModule {
1617

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /