public async Task <ICommandResult> Handle(DepartmentAddCommand mesage)
        {
            try
            {
                Department department = new Department();
                department.Init(mesage);

                await _roleService.AddToDb(department);

                await _eventSender.Notify(department.Events);

                ICommandResult result = new CommandResult
                {
                    Message  = "",
                    ObjectId = department.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.º 2
0
 public void Init(DepartmentAddCommand mesage)
 {
     Id     = mesage.Id;
     Name   = mesage.Name;
     Status = mesage.Status;
 }
Exemplo n.º 3
0
 public async Task <CommandResult> SendCommand(DepartmentAddCommand command)
 {
     return(await _commandService.SendAndReceiveResult <CommandResult>(command));
 }