public SellRequest GetSellRequest(RequestOwner owner) { foreach (var o in _requestListSell) { if (o.owner == owner) { return(o); } } return(null); }
public BuyRequest GetBuyRequest(RequestOwner owner) { foreach (var o in _requestListBuy) { if (o.owner == owner) { return(o); } } return(null); }
public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { if (context.HttpContext.Request.Headers.TryGetValue(UrlAndContextPropertiesNames.AUTHENTICATION_HEADER_NAME, out var token)) { var requestOwner = _memoryCacheFacade.Get <RequestOwner>(token[0]); if (requestOwner == null) { var tokenDetails = await _tokensManager.GetTokenDetailsFromDataStorgeAsync(token); if (tokenDetails == null) { SetUnauthorized(context); return; } var objectTenants = await _tenantObjectsManager.GetObjectTenantsAsync( tokenDetails.OwnerId, tokenDetails.MnemoxAccessObjectsType); if (objectTenants == null) { SetUnauthorized(context); return; } requestOwner = new RequestOwner { OwnerId = tokenDetails.OwnerId, MnemoxAccessObjectsType = tokenDetails.MnemoxAccessObjectsType, OwnerTenants = objectTenants }; var tokenTtlInMinutes = _tokensManager.GetTokenTtlMinutes(tokenDetails.ValidUntilDateTimeUtc.ToLocalTime()); _memoryCacheFacade.Set(tokenDetails.Token, requestOwner, TimeSpan.FromMinutes(tokenTtlInMinutes)); } context.HttpContext.Items.Add(UrlAndContextPropertiesNames.REQUEST_OWNER, requestOwner); await next(); } else { SetUnauthorized(context); } }
public bool OpenSellRequest(RequestOwner owner) { return(GetSellRequest(owner) != null); }
public bool OpenBuyRequest(RequestOwner owner) { return(GetBuyRequest(owner) != null); }