import 'product_component.dart';
import 'product_category_component.dart';
import 'product_detail_component.dart';
-import 'product_service.dart';
-import 'product_category_service.dart';
+
+import 'tables_component.dart';
@Component(
selector: 'my-app',
MaterialLayout
],
providers: const [
- ProductService,
- ProductCategoryService,
ROUTER_PROVIDERS
]
)
path: '/product/:id',
name: 'ProductDetail',
component: ProductDetailComponent
+ ),
+ const Route(
+ path: '/tables',
+ name: 'Tables',
+ component: TablesComponent
)
])
ProductCategoryComponent(this._prodcatSrv,this._router);
Future<Null> createProductCategory() async {
- await _prodcatSrv.createProdCategory(new_prod_category_name);
- await ngOnInit();
+ String id = await _prodcatSrv.createProdCategory(
+ new_prod_category_name
+ );
+ product_categories.add(new ProductCategory(
+ id,new_prod_category_name,'product_cetegory'
+ ));
+ new_prod_category_name='';
}
Future<Null> ngOnInit() async {
}
}
- Future<Null> createProdCategory(String name) async {
+ Future<String> createProdCategory(String name) async {
try {
- await _http.post(
+ var res = await _http.post(
_posturl,
headers: {'Content-Type': 'application/json'},
body: JSON.encode({
'type': 'product_category'
})
);
+ return(JSON.decode(res.body)['id']);
}
catch(e) {
throw _handleError(e);
await _prodSrv.updateProd(
prod.id,
prod_name,
- double.parse(prod_price),
+ prod_price,
prod_category
);
+ prod.price=prod_price;
+ prod.name=prod_name;
+ prod.category=prod_category;
}
}
}
}
- Future<Null> createProduct(String name,double price,String cat) async {
+ Future<String> createProduct(String name,double pri,String cat) async {
try {
var url=_server+'/'+_db;
var response = await _http.post(
headers: {'Content-Type': 'application/json'},
body: JSON.encode({
'name': name,
- 'price': price,
+ 'price': pri,
'type': 'product',
'category': cat
})