Try your search with a different keyword or use * as a wildcard.
using Microsoft.AspNetCore.Mvc;
using Nop.Services.Security;
using Nop.Web.Areas.Admin.Factories;
using Nop.Web.Areas.Admin.Models.Reports;
namespace Nop.Web.Areas.Admin.Controllers;
public partial class ReportController : BaseAdminController
{
#region Fields
protected readonly IPermissionService _permissionService;
protected readonly IReportModelFactory _reportModelFactory;
#endregion
#region Ctor
public ReportController(
IPermissionService permissionService,
IReportModelFactory reportModelFactory)
{
_permissionService = permissionService;
_reportModelFactory = reportModelFactory;
}
#endregion
#region Methods
#region Sales summary
public virtual async Task SalesSummary(List orderStatuses = null, List paymentStatuses = null)
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.SalesSummaryReport))
return AccessDeniedView();
//prepare model
var model = await _reportModelFactory.PrepareSalesSummarySearchModelAsync(new SalesSummarySearchModel
{
OrderStatusIds = orderStatuses,
PaymentStatusIds = paymentStatuses
});
return View(model);
}
[HttpPost]
public virtual async Task SalesSummaryList(SalesSummarySearchModel searchModel)
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.SalesSummaryReport))
return await AccessDeniedDataTablesJson();
//prepare model
var model = await _reportModelFactory.PrepareSalesSummaryListModelAsync(searchModel);
return Json(model);
}
#endregion
#region Low stock
public virtual async Task LowStock()
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageProducts))
return AccessDeniedView();
//prepare model
var model = await _reportModelFactory.PrepareLowStockProductSearchModelAsync(new LowStockProductSearchModel());
return View(model);
}
[HttpPost]
public virtual async Task LowStockList(LowStockProductSearchModel searchModel)
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageProducts))
return await AccessDeniedDataTablesJson();
//prepare model
var model = await _reportModelFactory.PrepareLowStockProductListModelAsync(searchModel);
return Json(model);
}
#endregion
#region Bestsellers
public virtual async Task Bestsellers()
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageOrders))
return AccessDeniedView();
//prepare model
var model = await _reportModelFactory.PrepareBestsellerSearchModelAsync(new BestsellerSearchModel());
return View(model);
}
[HttpPost]
public virtual async Task BestsellersList(BestsellerSearchModel searchModel)
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageOrders))
return await AccessDeniedDataTablesJson();
//prepare model
var model = await _reportModelFactory.PrepareBestsellerListModelAsync(searchModel);
return Json(model);
}
[HttpPost]
public virtual async Task BestsellersReportAggregates(BestsellerSearchModel searchModel)
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageOrders))
return await AccessDeniedDataTablesJson();
//prepare model
var totalAmount = await _reportModelFactory.GetBestsellerTotalAmountAsync(searchModel);
return Json(new { aggregatortotal = totalAmount });
}
#endregion
#region Never Sold
public virtual async Task NeverSold()
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageOrders))
return AccessDeniedView();
//prepare model
var model = await _reportModelFactory.PrepareNeverSoldSearchModelAsync(new NeverSoldReportSearchModel());
return View(model);
}
[HttpPost]
public virtual async Task NeverSoldList(NeverSoldReportSearchModel searchModel)
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageOrders))
return await AccessDeniedDataTablesJson();
//prepare model
var model = await _reportModelFactory.PrepareNeverSoldListModelAsync(searchModel);
return Json(model);
}
#endregion
#region Country sales
public virtual async Task CountrySales()
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.OrderCountryReport))
return AccessDeniedView();
//prepare model
var model = await _reportModelFactory.PrepareCountrySalesSearchModelAsync(new CountryReportSearchModel());
return View(model);
}
[HttpPost]
public virtual async Task CountrySalesList(CountryReportSearchModel searchModel)
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.OrderCountryReport))
return await AccessDeniedDataTablesJson();
//prepare model
var model = await _reportModelFactory.PrepareCountrySalesListModelAsync(searchModel);
return Json(model);
}
#endregion
#region Customer reports
public virtual async Task RegisteredCustomers()
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCustomers))
return AccessDeniedView();
//prepare model
var model = await _reportModelFactory.PrepareCustomerReportsSearchModelAsync(new CustomerReportsSearchModel());
return View(model);
}
public virtual async Task BestCustomersByOrderTotal()
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCustomers))
return AccessDeniedView();
//prepare model
var model = await _reportModelFactory.PrepareCustomerReportsSearchModelAsync(new CustomerReportsSearchModel());
return View(model);
}
public virtual async Task BestCustomersByNumberOfOrders()
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCustomers))
return AccessDeniedView();
//prepare model
var model = await _reportModelFactory.PrepareCustomerReportsSearchModelAsync(new CustomerReportsSearchModel());
return View(model);
}
[HttpPost]
public virtual async Task ReportBestCustomersByOrderTotalList(BestCustomersReportSearchModel searchModel)
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCustomers))
return await AccessDeniedDataTablesJson();
//prepare model
var model = await _reportModelFactory.PrepareBestCustomersReportListModelAsync(searchModel);
return Json(model);
}
[HttpPost]
public virtual async Task ReportBestCustomersByNumberOfOrdersList(BestCustomersReportSearchModel searchModel)
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCustomers))
return await AccessDeniedDataTablesJson();
//prepare model
var model = await _reportModelFactory.PrepareBestCustomersReportListModelAsync(searchModel);
return Json(model);
}
[HttpPost]
public virtual async Task ReportRegisteredCustomersList(RegisteredCustomersReportSearchModel searchModel)
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCustomers))
return await AccessDeniedDataTablesJson();
//prepare model
var model = await _reportModelFactory.PrepareRegisteredCustomersReportListModelAsync(searchModel);
return Json(model);
}
#endregion
#endregion
}