Exemplo n.º 1
0
 public void Init(RoleAddCommand mesage)
 {
     Id           = mesage.Id;
     Name         = mesage.Name;
     Status       = mesage.Status;
     DepartmentId = mesage.DepartmentId;
 }
        public async Task <ICommandResult> Handle(RoleAddCommand mesage)
        {
            try
            {
                Role role = new Role();
                role.Init(mesage);

                await _roleService.AddToDb(role);

                await _eventSender.Notify(role.Events);

                ICommandResult result = new CommandResult
                {
                    Message  = "",
                    ObjectId = role.Id,
                    Status   = CommandResult.StatusEnum.Sucess
                };
                return(result);
            }
            catch (Exception e)
            {
                e.Data["Param"] = mesage;
                ICommandResult result = new CommandResult()
                {
                    Message = e.Message,
                    Status  = CommandResult.StatusEnum.Fail
                };
                return(result);
            }
        }
Exemplo n.º 3
0
 public async Task <CommandResult> SendCommand(RoleAddCommand command)
 {
     return(await _commandService.SendAndReceiveResult <CommandResult>(command));
 }