Beispiel #1
0
        public override async Task AddAsync(FulanoModel model)
        {
            var command = new AddFulanoCommand()
            {
                Entity = _mapper.Map <Fulano>(model)
            };

            if (!command.IsValid())
            {
                await RaiseValidationErrorsAsync(command);

                return;
            }

            var listaFulano = await _fulanoRepository.GetAllAsync();

            if (listaFulano.Any(c => c.Id == command.Entity.Id))
            {
                await _mediatorHandler.RaiseDomainNotificationAsync(new DomainNotification(command.MessageType,
                                                                                           CoreUserMessages.RegistroExistente.Message));

                return;
            }

            if (listaFulano.Any(c => string.Equals(c.Nome, command.Entity.Nome, StringComparison.CurrentCultureIgnoreCase)))
            {
                await _mediatorHandler.RaiseDomainNotificationAsync(new DomainNotification(command.MessageType,
                                                                                           CoreUserMessages.ValorDuplicadoO.Format("Nome").Message));

                return;
            }

            await _mediatorHandler.SendCommandAsync(command);
        }
Beispiel #2
0
        public async Task <Response <Users> > ModifyAsync(UsersViewModel usersViewModel)
        {
            var modifyCommand = _mapper.Map <ModifyUsersCommand>(usersViewModel);
            //var user = await _mediator.Send(modifyCommand);
            var user = await Bus.SendCommandAsync(modifyCommand);

            return((Response <Users>)user);
        }
Beispiel #3
0
        public string Login(LoginViewModel gameViewModel)
        {
            var command = mapper.Map <SignInLoginCommand>(gameViewModel);

            mediator.SendCommandAsync(command);

            return(command.Token);
        }
Beispiel #4
0
        public async Task <IActionResult> Post([FromBody] CreateVehicleViewModel viewModel)
        {
            if (!viewModel.Validate())
            {
                return(await ResponseBase(viewModel.Notifications));
            }

            var command = new CreateVehicleCommand(viewModel.Chassis, viewModel.Color, viewModel.Type);
            var result  = await mediator.SendCommandAsync(command);

            return(await ResponseBase(result));
        }
        public async Task <CoreResult> Add([FromBody] BlogAddDto dto)
        {
            CoreResult     result  = new CoreResult();
            BlogAddCommand command = new BlogAddCommand(dto.Name, dto.Url);
            var            res     = await _bus.SendCommandAsync(command);

            if (res)
            {
                result.Success("添加成功");
            }
            else
            {
                result.Failed("添加失败");
            }
            return(result);
        }
Beispiel #6
0
        public async Task <CoreResult> Create([FromBody] CreateCompanyRequestDto dto)
        {
            CoreResult           result  = new CoreResult();
            CreateCompanyCommand command = new CreateCompanyCommand(dto.Name, dto.SkuPrefix, dto.AdditionalFee);
            var res = await _bus.SendCommandAsync(command);

            if (res)
            {
                result.Success("添加成功");
            }
            else
            {
                result.Failed("添加失败");
            }
            return(result);
        }
Beispiel #7
0
        public async Task <CoreResult> Create([FromBody] CreateShopRequestDto dto)
        {
            CoreResult        result  = new CoreResult();
            CreateShopCommand command = new CreateShopCommand(dto);
            var res = await _bus.SendCommandAsync(command);

            if (res)
            {
                result.Success("添加成功");
            }
            else
            {
                result.Failed("添加失败");
            }
            return(result);
        }
Beispiel #8
0
        public override async Task AddAsync(UserModel model)
        {
            var command = new AddUserCommand()
            {
                Entity = _mapper.Map <User>(model)
            };

            if (!command.IsValid())
            {
                await RaiseValidationErrorsAsync(command);

                return;
            }

            var listaUser = await _userRepository.GetAllAsync();

            if (listaUser.Any(c => c.Id == command.Entity.Id))
            {
                await _mediatorHandler.RaiseDomainNotificationAsync(new DomainNotification(command.MessageType,
                                                                                           CoreUserMessages.RegistroExistente.Message));

                return;
            }

            if (listaUser.Any(c => string.Equals(c.Username, command.Entity.Username, StringComparison.CurrentCultureIgnoreCase)))
            {
                await _mediatorHandler.RaiseDomainNotificationAsync(new DomainNotification(command.MessageType,
                                                                                           CoreUserMessages.ValorDuplicadoO.Format("Username").Message));

                return;
            }

            command.Entity.Password = PasswordHashService.Hash(command.Entity.Password);

            await _mediatorHandler.SendCommandAsync(command);
        }
Beispiel #9
0
        public async Task <CoreResult> AsyncCountry()
        {
            CoreResult          result  = new CoreResult();
            AsyncCountryCommand command = new AsyncCountryCommand();
            var res = await _bus.SendCommandAsync(command);

            if (res)
            {
                result.Success("国家同步成功");
            }
            else
            {
                result.Failed("国家同步失败");
            }
            return(result);
        }
Beispiel #10
0
        public async Task <bool> Create([FromBody] CreatePostDTO req)
        {
            CreatePostCommand command = new CreatePostCommand(req.Title, req.Content, req.BlogId);

            return(await _bus.SendCommandAsync(command));
        }
Beispiel #11
0
        public void Activate(Guid id)
        {
            var command = new ActivatePersonCommand(id);

            mediator.SendCommandAsync(command);
        }
 public async Task<IActionResult> OrderAsync()
 {
      var command = new OrderAsyncCommand();
      await _bus.SendCommandAsync(command);
      return Ok();
 }
        public Task <bool> SendMessage([FromBody] SendMessageRequestDTO req)
        {
            SendMessageCommand command = new SendMessageCommand(req);

            return(_bus.SendCommandAsync(command));
        }
Beispiel #14
0
        public async Task <bool> Create([FromBody] CreateDTO model)
        {
            var command = new CreateTestCommand(model.Name);

            return(await _bus.SendCommandAsync(command));
        }