private dynamic GetUserDetails()
        {
            var users = new List <User>();
            var names = _firebaseHelper.GetUserNamesAsync().Result;

            foreach (var name in names)
            {
                var user = _firebaseHelper.GetUserAsync(name).Result;
                user.Xp = _xpAggregator.CalculateXp(user.XpHistory);
                _levelEngine.CalculateLevel(user);

                users.Add(user);
            }

            return(Response.AsJson(users));
        }
        public bool ApplyTracking(string xpModelUserName, int xpModelXp, IntegrationsProviderTypes integrationProvider, ActionType actionType)
        {
            var success = true;

            var user = GetUser(xpModelUserName);

            #region xp logic

            switch (actionType)
            {
            case ActionType.Add:
                user.Xp += xpModelXp;
                break;

            case ActionType.Remove:
                user.Xp -= xpModelXp;
                break;

            default:
                break;
            }


            try
            {
                var eventItem = new EventItem(xpModelXp, integrationProvider, actionType);
                _firebaseHelper.CreateXPRecordAsync(xpModelUserName.Replace('.', ','), eventItem);
            }
            catch (Exception e)
            {
                return(false);
            }
            #endregion xp logic

            #region level logic

            var orginallevel = user.Level;
            Thread.Sleep(1000);
            user = GetUser(xpModelUserName);
            _levelEngine.CalculateLevel(user);

            if (user.Level != orginallevel)
            {
                try
                {
                    var eventItem = new GeneralItem(user.Level, actionType);
                    _firebaseHelper.CreateLevelRecordAsync(xpModelUserName.Replace('.', ','), eventItem);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
            #endregion level logic

            #region Gear

            if (actionType == ActionType.Add)
            {
                var totalGearToAdd = xpModelXp / 50;

                for (var i = 0; i < totalGearToAdd; i++)
                {
                    try
                    {
                        var gearItem = _armoury.CreateRandomWeapon();

                        var eventItem = new GeneralItem(gearItem.Id, ActionType.Add);
                        _firebaseHelper.CreateGearRecordAsync(xpModelUserName.Replace('.', ','), eventItem);
                    }
                    catch (Exception e)
                    {
                        return(false);
                    }
                }
            }

            #endregion Gear

            return(success);
        }