nopcommerce - Rest api Method call morethan one time -
i develop rest api plugin method in nopcommerce getting product list product table, how method call 2 times ! want call ones.
public ilist<productallresponse> getallproducts(string apisecretkey, int storeid, int languageid) { var _productrepository = enginecontext.current.resolve<irepository<product>>(); var getallproducts = new list<productallresponse>(); try { if (!checkapikey(apisecretkey, storeid)) { getallproducts.add(new productallresponse { message = _localizationservice.getresource("plugins.xcellenceit.restapi.message.checkapi") }); return getallproducts; } var query = (from p in _productrepository.table p.published && !p.deleted select new { id = p.id, name = p.name }).tolist(); foreach (var item in query) { getallproducts.add(new productallresponse { id = item.id, name = item.name }); } return getallproducts; } catch (exception exc) { _logger.error(exc.message); getallproducts.add(new productallresponse { message = exc.message }); return getallproducts; } }
here issue in productallresponse, response class inherited other class contextclass, , both of class has same property called id.
when removed id productallresponse , it's call 1 time.
Comments
Post a Comment