public void HandleRequest(IRequest request) { using (var scope = Db.CreateTransaction()) { var encryptedTicket = request.Data.GetOrDefault <byte[]>("encData"); var steamId = _steamManager.GetSteamId(encryptedTicket); if (string.IsNullOrEmpty(steamId)) { throw new PerpetuumException(ErrorCodes.SteamDecodingError); } var accounts = _accountRepository.GetBySteamId(steamId).ToList(); if (accounts.Count <= 0) { var newAccount = CreateNewSteamAccount(steamId); accounts.Add(newAccount); } Transaction.Current.OnCommited(() => { var accountInfos = accounts.ToDictionary("a", a => a.ToDictionary()); Message.Builder.FromRequest(request).WithData(accountInfos).Send(); }); scope.Complete(); } }
protected override Account LoadAccount(IRequest request) { if (_steamManager.SteamAppID <= 0) { throw new PerpetuumException(ErrorCodes.SteamLoginDisabled); } var encryptedTicket = request.Data.GetOrDefault <byte[]>("encData"); var accountId = request.Data.GetOrDefault <int>(k.accountID); var steamId = _steamManager.GetSteamId(encryptedTicket); return(_accountRepository.Get(accountId, steamId)); }