Try your search with a different keyword or use * as a wildcard.
using Microsoft.AspNetCore.Mvc;
using Nop.Core;
using Nop.Services.Security;
using Nop.Web.Areas.Admin.Factories;
using Nop.Web.Framework.Components;
namespace Nop.Web.Areas.Admin.Components;
///
/// Represents a view component that displays common statistics
///
public partial class CommonStatisticsViewComponent : NopViewComponent
{
#region Fields
protected readonly ICommonModelFactory _commonModelFactory;
protected readonly IPermissionService _permissionService;
protected readonly IWorkContext _workContext;
#endregion
#region Ctor
public CommonStatisticsViewComponent(ICommonModelFactory commonModelFactory,
IPermissionService permissionService,
IWorkContext workContext)
{
_commonModelFactory = commonModelFactory;
_permissionService = permissionService;
_workContext = workContext;
}
#endregion
#region Methods
///
/// Invoke view component
///
///
/// A task that represents the asynchronous operation
/// The task result contains the view component result
///
public async Task InvokeAsync()
{
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCustomers) ||
!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageOrders) ||
!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageReturnRequests) ||
!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageProducts))
{
return Content(string.Empty);
}
//a vendor doesn't have access to this report
if (await _workContext.GetCurrentVendorAsync() != null)
return Content(string.Empty);
//prepare model
var model = await _commonModelFactory.PrepareCommonStatisticsModelAsync();
return View(model);
}
#endregion
}