Exemple #1
0
        // Tweet Controller
        private static bool NewTweet(Tweet tweet)
        {
            // Check for validity
            if (!Validator.IsTweetValid(tweet))
            {
                error = Validator.Error;
                return(false);
            }

            // Generate ID
            tweet.Id = IdGeneratorSingleton.Instance.NewTweetId();

            // Sanitize
            Sanitizer.SanitizeTweet(tweet);

            // Add to the list in memory
            DataBaseSingleton.Instance.TweetList.Add(tweet);

            // Serialize
            Persistence.Serialize();

            // Display it
            ProcessedMessage processedMessageWindow = new ProcessedMessage(tweet);

            processedMessageWindow.Show();

            return(true);
        }
Exemple #2
0
        // Controller for message of type SMS
        private static bool NewSms(Sms sms)
        {
            // Check for validity
            if (!Validator.IsSmsValid(sms))
            {
                error = Validator.Error;
                return(false);
            }

            // Generate ID
            sms.Id = IdGeneratorSingleton.Instance.NewSmsId();

            // Sanitize
            Sanitizer.SanitizeSms(sms);

            // Add to the list in memory
            DataBaseSingleton.Instance.SmsList.Add(sms);

            // Serialize
            Persistence.Serialize();

            // Display it
            ProcessedMessage processedMessageWindow = new ProcessedMessage(sms);

            processedMessageWindow.Show();

            return(true);
        }
Exemple #3
0
        // Email Controller
        private static bool NewEmail(Email email)
        {
            // Check for validity
            if (!Validator.IsEmailValid(email))
            {
                error = Validator.Error;
                return(false);
            }

            // Generate ID
            email.Id = IdGeneratorSingleton.Instance.NewEmailId();

            // Sanitize
            Sanitizer.SanitizeEmail(email);

            // Add to the list in memory
            DataBaseSingleton.Instance.EmailList.Add(email);

            // Serialize
            Persistence.Serialize();

            // Display it
            ProcessedMessage processedMessageWindow = new ProcessedMessage(email);

            processedMessageWindow.Show();

            return(true);
        }