Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

747 B
Raw Blame
#nullable enable

using Grand.Domain.Catalog;
using Grand.Infrastructure;
using Grand.Web.AdminShared.Interfaces;

namespace Grand.Web.AdminShared.Services;

public class VendorProductDataScope(IContextAccessor contextAccessor) : IAdminDataScope<Product>
{
    public Task<bool> HasAccess(Product entity)
    {
        if (entity is null) return Task.FromResult(false);
        return Task.FromResult(entity.VendorId == contextAccessor.WorkContext.CurrentVendor.Id);
    }

    public string? DefaultStoreId => null;

    public string ResourceKeyPrefix => "Vendor";

    public bool ShowStoreSelector => false;

    public string? DefaultVendorId => contextAccessor.WorkContext.CurrentVendor.Id;

    public bool CanFeatureOnHomepage => false;
}