nopCommerce を使用して 2 つのリストを返そうとしています。どちらのリストも読み取り専用です。地下鉄アプリを作成していて、MVC の学習に何週間も費やしたくないので、これを行う最も簡単な方法を探しています。最初のリストはベース nopCommerce プラットフォームのカテゴリのリストで、2 番目のリストは製品のリストです。どちらのリストも、JSON として呼び出し元のクライアントに返す必要があります。
2 つの質問があります。
- カスタムコードを呼び出さずにこのリストを取得する方法はありますか?
次のコードを使用してプラグインを作成しました
using System.Collections; using System.Collections.Generic; using System.Web.Mvc; using Nop.Core; using Nop.Core.Domain.Catalog; using Nop.Services.Catalog; using Nop.Services.Customers; using Nop.Core.Plugins; namespace Nop.Plugin.Other.ONWWW.Controllers { public class ONWWWController : Controller { public ICategoryService _categoryService; public ONWWWController(ICategoryService categoryService) { this._categoryService = categoryService; } public ActionResult Index() { return Json(_categoryService.GetAllCategories(), JsonRequestBehavior.AllowGet); } } }
コードを実行すると、次のエラーが表示されるのはなぜですか?
このオブジェクトにはパラメーターなしのコンストラクターが定義されていません。