I'm using Nopcommerce with source code right now I want to implement the code about count visitor for my E-Commerce website but I'm stunned on how to retrieve data from the SQL server to implement code on my project. I know I need to customize in Customer table from database but I don't know how to implement the code to get the result in the picture below.
for the next step. I want to do coding for my project. But I don't know where the ado or entity for connecting through the database. Now, I have a query for filtering the online users. Could you help me to do coding and connect the database on my project. The code is too complex for me.
<div> @{ var onlineCustomerMinutes = EngineContext.Current.Resolve<CustomerSettings>().OnlineCustomerMinutes;
var onLineCustomer = EngineContext.Current.Resolve<ICustomerService>().GetOnlineCustomers(DateTime.UtcNow.AddMinutes(-onlineCustomerMinutes), null).Count();
var getcustomerLastweek = EngineContext.Current.Resolve<ICustomerService>().GetAllCustomers(DateTime.UtcNow, DateTime.UtcNow.AddDays(-7)).Count(); var getAllcustomer = EngineContext.Current.Resolve<ICustomerService>().GetAllCustomers().Count();
<h3>Online : @onLineCustomer | This week : @getcustomerLastweek | Total : @getAllcustomer</h3> } </div>
The method declaration is GetAllCustomers(DateTime? createdFromUtc = null, DateTime? createdToUtc = null,...
I.e. I'd think the call should have the date params reversed:
var getcustomerLastweek = EngineContext.Current.Resolve<ICustomerService>().GetAllCustomers(DateTime.UtcNow.AddDays(-7), DateTime.UtcNow).Count();
P.S. It would be best to just resolve ICustomerService once - e.g.
var customerService = EngineContext.Current.Resolve<ICustomerService>(); ... var onLineCustomer = customerService.GetOnlineCustomers(DateTime.UtcNow.AddMinutes(-onlineCustomerMinutes),null).Count(); var getcustomerLastweek = customerService.GetAllCustomers(DateTime.UtcNow, DateTime.UtcNow.AddDays(-7)).Count(); var getAllcustomer = customerService.GetAllCustomers().Count();