コード例 #1
0
        public static PushNotificationMessage BuildGameMessage(PushNotificationMessageTypeEnum type, Athlete athlete, int gameHostID)
        {
            string name = athlete.Name ?? "";

            if (name.Length > 20)
            {
                name = name.Substring(0, 20);
            }
            string text;

            switch (type)
            {
            case PushNotificationMessageTypeEnum.GameInvite: text = string.Format("Game invite from '{0}'", name); break;

            case PushNotificationMessageTypeEnum.GameInviteAccepted: text = string.Format("Invite accepted by '{0}'", name); break;

            case PushNotificationMessageTypeEnum.GameInviteDeclined: text = string.Format("Invite declined by '{0}'", name); break;

            case PushNotificationMessageTypeEnum.GameWantsToBeInvited: text = string.Format("Wants to be invited: '{0}'", name); break;

            case PushNotificationMessageTypeEnum.GameApprovedByHost: text = string.Format("Approved by '{0}'. Come play!", name); break;

            default: throw new Exception("Invalid type: " + type.ToString());
            }
            return(new PushNotificationMessage()
            {
                Text = text, ObjectID = gameHostID
            });
        }
コード例 #2
0
        internal BL_PushNotificationMessageTypeEnum From(PushNotificationMessageTypeEnum key)
        {
            switch (key)
            {
            case PushNotificationMessageTypeEnum.Type_EBA_Points_Sent:
                return(BL_PushNotificationMessageTypeEnum.Type_EBA_Points_Sent);

            case PushNotificationMessageTypeEnum.Unknown:
                throw new BusinessLogicException(ValidationErrorCode.NotFound, "", $"Unable to map enum of type {nameof(PushNotificationMessageTypeEnum)} with with value '{key}' to value of type {nameof(BL_PushNotificationMessageTypeEnum)}");

            default:
                throw new BusinessLogicException(ValidationErrorCode.NotFound, "", $"Unable to map enum of type {nameof(PushNotificationMessageTypeEnum)} with with value '{key}' to value of type {nameof(BL_PushNotificationMessageTypeEnum)}");
            }
        }