Beispiel #1
0
        /// <summary>
        /// Executes the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        public void Execute(MarkCommentAsSpamCommand command)
        {
            Momento momento = _database.SingleOrDefault <Momento>((m) => m.Id == command.MomentoId);

            momento.MarkCommentAsSpam(command.CommentId);

            _database.Add(momento);
        }
Beispiel #2
0
        /// <summary>
        /// Executes the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        public void Execute(HomeIndexCommand command)
        {
            User momento = new User();

            //momento.Visibility = Visibility.Private;
            _database.Add(momento);
            _database.Save();
        }
Beispiel #3
0
        /// <summary>
        /// Executes the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        public void Execute(CreateUserCommand command)
        {
            var user      = PopulateUser(command);
            var foundUser = CheckForDuplicateUsername(user);

            if (foundUser != null)
            {
                throw new DuplicateUsernameException(string.Format("Username '{0}' already exists.", user.Username));
            }

            _database.Add(user);
        }
Beispiel #4
0
        /// <summary>
        /// Executes the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        public void Execute(CreateCommentCommand command)
        {
            Momento momento = _database.SingleOrDefault <Momento>(c => c.Id == command.MomentoId);
            Comment comment = new Comment();

            comment.Author      = comment.Author;
            comment.AuthorEmail = command.AuthorEmail;
            comment.AuthorUrl   = command.AuthorUrl;
            comment.Body        = comment.Body;
            comment.UserAgent   = command.UserAgent;
            comment.UserIp      = command.UserIp;

            momento.AddComment(comment);

            _database.Add(momento);
            _database.Save();

            CommentMessage commentMessage = ConvertToCommentMessage(comment);

            _bus.Send(commentMessage);
        }