public SaleOrdersController(AlpsContext context) { _context = context; }
public WarehouseVoucherApiController() { unitOfWork = new AlpsContext(); warehouseVoucherAS = new WarehouseVoucherAppService(unitOfWork); }
public StockOutVouchersController(AlpsContext context, StockService stockService) { this._context = context; this._stockService = stockService; }
public CustomersController(AlpsContext context) { _context = context; }
public LogisticsController(AlpsContext context) { this._context = context; }
public CatagoryApiController() { unitOfWork = new AlpsContext(); catagoryService = new CatagoryService(unitOfWork); }
public PurchaseOrdersController(AlpsContext context) { this._context = context; }
public PurchaseMgrService(AlpsContext db) { this.db = db; }
public async Task Invoke(HttpContext context, AlpsContext dbContext) { var endpoint = context.GetEndpoint(); var authorizeData = endpoint?.Metadata.GetOrderedMetadata <IAuthorizeData>() ?? Array.Empty <IAuthorizeData>(); // 如果没有 [Authorize] 就不需要拦截 if (authorizeData == null || authorizeData.Count == 0) { await _next(context); return; } // 如果有 [AllowAnonymous],那也不需要拦截 if (endpoint?.Metadata.GetMetadata <IAllowAnonymous>() != null) { await _next(context); return; } if (context.User.IsInRole("Admin")) { await _next(context); return; } var controllerName = endpoint.Metadata.GetMetadata <ControllerActionDescriptor>().ControllerName; var actionName = endpoint.Metadata.GetMetadata <ControllerActionDescriptor>().ActionName; var userName = context.User.Identity.Name; var query = await( dbContext.AlpsUsers.Include(p => p.RoleUsers).ThenInclude(p => p.Role).ThenInclude(p => p.Permissions).ThenInclude(p => p.Resource) .AnyAsync(p => p.RoleUsers.Any(l => l.Role.Permissions.Any(k => k.Resource.Controller == controllerName && k.Resource.Action == actionName)))); /* * from u in dbContext.AlpsUsers.Include(p=>p.RoleUsers).ThenInclude(p=>p.Role).ThenInclude(p=>p.Permissions).ThenInclude(p=>p.Resource) * * from r in dbContext.AlpsResources * where r.Permissions. * // from role in dbContext.AlpsRoles * where u.IDName == userName && u.RoleUsers. && * (from r in dbContext.AlpsResources * join p in dbContext.Permissions on r.ID equals p.ResourceID * where r.Controller == controllerName && r.Action == actionName * select p.RoleID).Contains(role.ID) * select u.ID).CountAsync(); */ if (!query) { if (context.User.Identity.IsAuthenticated) { context.Response.StatusCode = 403; context.Response.Headers.Add("WWW-Authenticate", new Microsoft.Extensions.Primitives.StringValues("Login authorization failed")); return; } else { context.Response.StatusCode = 401; context.Response.Headers.Add("WWW-Authenticate", new Microsoft.Extensions.Primitives.StringValues("Login authentication failed")); return; } } await _next(context); return; }
public ProductMgrService(AlpsContext db) { this.db = db; }
public SaleService(AlpsContext context) { this._context = context; }
public StockService(AlpsContext db) { this.db = db; }
public ProductService(AlpsContext context) { this._context = context; }
public LendersController(AlpsContext context) { _context = context; }
public ProductsController(AlpsContext context) { _context = context; }
public StockService(AlpsContext context) { this._context = context; }
public CommoditiesController(AlpsContext context) { _context = context; }
public SaleMgrAppService(AlpsContext db) { this.db = db; }
public QueryController(AlpsContext context) { _context = context; }
public TradeAccountsController(AlpsContext context) { this._context = context; }
public StocksController(AlpsContext context) { _context = context; }
public PositionsController(AlpsContext context) { this._context = context; }
public AuthController(AlpsContext context, AlpsJwtOption jwtOption) { this._context = context; this._jwtOption = jwtOption; }
public SuppliersController(AlpsContext context) { _context = context; }
public AddressService(AlpsContext context) { this._context = context; }
public UsersController(AlpsContext context, IActionDescriptorCollectionProvider actionProvider) { _context = context; _actionProvider = actionProvider; }
public StockInVouchersController(AlpsContext context, StockService stockService) { this._context = context; this._stockService = stockService; //this._context.Database.Log = (s) => Console.WriteLine(s); }
public UnitsController(AlpsContext context) { _context = context; }
public CatagoriesController(AlpsContext context) { this._context = context; }
public LoanVouchersController(AlpsContext context) { _context = context; }