Пример #1
0
        public IHttpActionResult UpdateText(string id, [FromBody] dynamic model)
        {
            var textId            = new Guid(id);
            var changeTextCommand = new ChangeTextCommand
            {
                Id      = Guid.NewGuid(),
                Content = model.Content,
                Title   = model.Title,
                TextId  = textId
            };

            CommandSender.Publish(changeTextCommand);
            return(Ok());
        }
Пример #2
0
        public IHttpActionResult UpdateUser(Guid id, [FromBody] dynamic model)
        {
            var email             = (string)model.Email;
            var displayName       = (string)model.DisplayName;
            var updateUserCommand = new UpdateUserCommand
            {
                UserId      = id,
                Email       = email,
                DisplayName = displayName
            };

            CommandSender.Publish(updateUserCommand);
            return(Ok());
        }
Пример #3
0
        public IHttpActionResult CreateText([FromBody] dynamic model)
        {
            var textId            = Guid.NewGuid();
            var createTextCommand = new CreateTextCommand
            {
                Id      = Guid.NewGuid(),
                Content = model.Content,
                Title   = model.Title,
                UserId  = model.UserId,
                TextId  = textId
            };

            CommandSender.Publish(createTextCommand);
            return(Ok(textId));
        }
Пример #4
0
        public IHttpActionResult CreateUser([FromBody] dynamic model)
        {
            var userId            = Guid.NewGuid();
            var createUserCommand = new CreateUserCommand
            {
                Id          = Guid.NewGuid(),
                UserId      = userId,
                Name        = model.Name,
                Password    = model.Password,
                Email       = model.Email,
                DisplayName = model.DisplayName
            };

            CommandSender.Publish(createUserCommand);
            return(Ok(userId));
        }
Пример #5
0
        public virtual void Publish <TCommand>(TCommand command)
            where TCommand : ICommand <TAuthenticationToken>
        {
            RouteHandlerDelegate commandHandler;

            if (!PrepareAndValidateCommand(command, out commandHandler))
            {
                return;
            }

            // This could be null if Akka won't handle the command and something else will.
            if (commandHandler != null)
            {
                commandHandler.Delegate(command);
            }

            // Let everything else know about the command (usually double handling a command is bad... but sometimes it might be useful... like pushing from AWS to Azure so both systems handle it... although an event really is the proper pattern to use here.
            CommandSender.Publish(command);
        }