How to Inject Service in Razor View File Nopcommerce 3.8 Version

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
2 anni tempo fa
Hello  Team,
I want to use a service method direct in  razor view
I'm trying to inject that service as mentioned below. But it is not working in NopCommerce 3.8 Version
@Inject ICustomerService customerService;
How may  I utilized any Nop.Servece method in  my .cshtml  file
Anyone Help  would be highly appriciated.
2 anni tempo fa
Finally Got the Solution  which was quick easy . But sometime we look in hard way.

@using Nop.Services.Customers;
@using Nop.Core.Infrastructure;

var id="yourvalue";
var objdata= EngineContext.Current.Resolve<ICustomerService>().GetCustomerById(id);

I hope it will  help  someone.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.