private async Task <SteamUser> CreateDefaultRustUser()
        {
            Guid newSteamUserGuid;

            do
            {
                newSteamUserGuid = Guid.NewGuid();
            } while (_easyShopContext.SteamUsers.FirstOrDefault(x => x.Id == newSteamUserGuid) != null);

            var newSteamUser = new SteamUser
            {
                Id         = newSteamUserGuid,
                Uid        = "76561198882487777",
                TotalSpent = 0m
            };

            var newSteamUserShop = new SteamUserShop
            {
                Shop       = _newShop,
                SteamUser  = newSteamUser,
                Balance    = _newShop.StartBalance,
                TotalSpent = 0m
            };

            _easyShopContext.SteamUsers.Add(newSteamUser);
            _easyShopContext.SteamUsersShops.Add(newSteamUserShop);
            await _easyShopContext.SaveChangesAsync();

            return(newSteamUser);
        }
        public async Task InvokeAsync(HttpContext httpContext, EasyShopContext easyShopContext, IRustShopService rustShopService)
        {
            _easyShopContext = easyShopContext;
            _rustShopService = rustShopService;

            EasyShop.Domain.Entries.Shop.Shop shop = null;

            try
            {
                var tenantContext = httpContext.GetMultiTenantContext();
                shop = _rustShopService.GetShopById(Guid.Parse(tenantContext.TenantInfo.Id));
            }
            catch
            {
                await _next(httpContext);
            }

            if (httpContext.User.Identity.IsAuthenticated)
            {
                var steamUser = _easyShopContext.SteamUsers.FirstOrDefault(x => x.Uid == GetSteamUserUid(httpContext));

                if (steamUser is null)
                {
                    Guid newSteamUserGuid;

                    do
                    {
                        newSteamUserGuid = Guid.NewGuid();
                    } while (_easyShopContext.SteamUsers.FirstOrDefault(x => x.Id == newSteamUserGuid) != null);

                    var newSteamUser = new SteamUser
                    {
                        Id         = newSteamUserGuid,
                        Uid        = GetSteamUserUid(httpContext),
                        TotalSpent = 0m
                    };

                    if (shop != null)
                    {
                        var newSteamUserShop = new SteamUserShop
                        {
                            Shop       = shop,
                            SteamUser  = newSteamUser,
                            Balance    = shop.StartBalance,
                            TotalSpent = 0m
                        };

                        _easyShopContext.SteamUsersShops.Add(newSteamUserShop);
                    }

                    _easyShopContext.SteamUsers.Add(newSteamUser);
                    await _easyShopContext.SaveChangesAsync();
                }
                else
                {
                    var steamUserShop =
                        _easyShopContext.SteamUsersShops.FirstOrDefault(x =>
                                                                        x.SteamUser.Id == steamUser.Id && x.Shop.Id == shop.Id);

                    if (steamUserShop is null)
                    {
                        var newSteamUserShop = new SteamUserShop
                        {
                            Shop         = shop,
                            SteamUser    = steamUser,
                            Balance      = shop.StartBalance,
                            TotalSpent   = 0m,
                            StartBalance = shop.StartBalance
                        };

                        _easyShopContext.SteamUsersShops.Add(newSteamUserShop);
                        await _easyShopContext.SaveChangesAsync();
                    }
                }
            }

            await _next(httpContext);
        }