public EventItem(int value, IntegrationsProviderTypes integrationId, ActionType actionType)
 {
     IntegrationId = integrationId;
     ActionType    = actionType;
     TimeStamp     = DateTime.UtcNow.ToString("O");
     Value         = value;
 }
        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);
        }