asp.net - EmberJS RESTAdapter with extra parameters -
i have emberjs application uses asp .net restfull web api fetch data server. use ember restadapter connect web api, , works great these scenarios:
get products //findall products/{id} //find post products //createrecord put products/{id} //updaterecord delete products/{id} //deleterecord
but if encounter scenario:
get products?categoryid=1
how can call method via ember , process result?
my asp.net rest api controller
public class productscontroller : apicontroller { private iordercapturerepository _ordercapture; public productscontroller() { _ordercapture = new ordercapturerepository(); } public ihttpactionresult get() { try { var result = wrapper.wraptoember(_ordercapture.getproducts()); return ok(result); } catch (exception e) { return internalservererror(e); } } public ihttpactionresult get(int id) { try { var result = wrapper.wraptoember(_ordercapture.getproduct(id)); if (result == null) { return notfound(); } return ok(result); } catch (exception e) { return internalservererror(); } } [httpget] public ihttpactionresult getproductsincategory(int categoryid) { try { var result = wrapper.wraptoember(_ordercapture.getproducts(categoryid)); return ok(result); } catch (exception e) { return internalservererror(); } } }
my adapter:
import ds 'ember-data'; var applicationadapter = ds.restadapter.extend({ }); applicationadapter.reopen({ host: 'http://localhost:52703/', namespace: 'api/' }); export default applicationadapter;
after posting question discovered findquery method on restadapter provided ember. solves problem!
Comments
Post a Comment