Example #1
0
        public void Register(PedidoViewModel pedidoViewModel)
        {
            var registerCommand = _mapper.
                                  Map <RegisterNewPedidoCommand>(pedidoViewModel);

            bus.SendCommand(registerCommand);
        }
Example #2
0
        public async Task <BaseResult> AddAsync(CreateUserDto dto)
        {
            var command = _mapper.Map <CreateUserCommand>(dto);
            var result  = await _bus.SendCommand <CreateUserCommand, BaseResult>(command);

            return(result);
        }
Example #3
0
        public async Task <CommandResponse> AddEmployee(EmployeeViewModel employeeViewModel)
        {
            var employeeCommand = _mapper.Map <EmployeeAddCommand>(employeeViewModel);
            var res             = await _mediatorHandler.SendCommand <EmployeeAddCommand>(employeeCommand);

            return(res);
        }
Example #4
0
        public Task <AddNewProductResponse> addNewProduct(AddNewProductRequest request)
        {
            AddNewProductCommand command = new AddNewProductCommand
                                           (
                request.Product.Name,
                request.Product.Note,
                request.Product.Code,
                request.Product.OtherUnitOfProduct,
                request.Product.UnitId,
                request.Product.WeightPerUnit,
                request.Product.Preservation.ID
                                           );
            Task <object> product = (Task <object>)Bus.SendCommand(command);
            //RabbitMQBus.Publish(command);
            AddNewProductResponse response = new AddNewProductResponse();

            response = Common <AddNewProductResponse> .checkHasNotification(_notifications, response);

            if (response.Success)
            {
                ProductModel ProductModel = (ProductModel)product.Result;
                response.Data = ProductModel.Id;
            }
            return(Task.FromResult(response));
        }
Example #5
0
        private async Task <AccountDetailVm> GetAccountDetail(long id)

        {
            var accountInfo = await AccountRepositoryHelper.GetAccountInfo(id, _accountRep, _redisRep);

            if (accountInfo == null)
            {
                return(null);
            }
            var tMoney = _moneyClient.GetResponseExt <GetMoneyMqCmd, WrappedResponse <MoneyMqResponse> >
                             (new GetMoneyMqCmd(id));

            var tLevel = _bus.SendCommand(new GetLevelInfoCommand(id));
            var tGame  = _bus.SendCommand(new GetGameInfoCommand(id));
            await Task.WhenAll(tMoney, tLevel, tGame);

            var moneyResponse = tMoney.Result;
            var moneyInfo     = new MoneyInfoVm(moneyResponse.Message.Body.CurCoins + moneyResponse.Message.Body.Carry,
                                                moneyResponse.Message.Body.CurDiamonds,
                                                moneyResponse.Message.Body.MaxCoins,
                                                moneyResponse.Message.Body.MaxDiamonds);
            var levelInfo = _mapper.Map <LevelInfoVm>(tLevel.Result.Body);
            var gameInfo  = _mapper.Map <GameInfoVm>(tGame.Result.Body);

            if (accountInfo == null || moneyInfo == null || levelInfo == null || gameInfo == null)
            {
                return(null);
            }
            return(new AccountDetailVm(accountInfo.PlatformAccount,
                                       accountInfo.UserName, accountInfo.Sex, accountInfo.HeadUrl,
                                       accountInfo.Type, levelInfo, gameInfo, moneyInfo));
        }
Example #6
0
        public async Task <IActionResult> AdicionarItem(Guid id, int quantidade)
        {
            var produto = await _produtoAppService.GetById(id);

            if (produto == null)
            {
                return(BadRequest());
            }

            if (produto.QuantidadeEstoque < quantidade)
            {
                TempData["Erro"] = "Produto com estoque insuficiente";
                return(RedirectToAction("ProdutoDetalhe", "Vitrine", new { id }));
            }

            var command = new AdicionarItemPedidoCommand(ClienteId, produto.Id, produto.Nome, quantidade, produto.Valor);
            await _mediatorHandler.SendCommand(command);

            if (OperacaoValida())
            {
                return(RedirectToAction("Index"));
            }

            TempData["Erros"] = GetMensagensErro();
            return(RedirectToAction("ProdutoDetalhe", "Vitrine", new { id }));
        }
Example #7
0
        public async Task <IActionResult> Cadastrar([FromBody] CadastrarClienteViewModel cadastrarClienteViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(Response(cadastrarClienteViewModel));
            }

            await _mediatorHandler.SendCommand(_mapper.Map <CadastrarClienteCommand>(cadastrarClienteViewModel));

            if (!OperacaoValida())
            {
                return(Response(cadastrarClienteViewModel));
            }

            var cliente = _clienteRepository.ObterPorId(cadastrarClienteViewModel.Id);

            var usuarioViewModel = new UsuarioViewModel
            {
                Id          = cliente.Id,
                TipoUsuario = TipoUsuario.Cliente
            };

            return(Response(new
            {
                token = ConfiguracoesSeguranca.GerarToken(usuarioViewModel),
                cliente = _mapper.Map <ClienteViewModel>(cliente)
            }));
        }
Example #8
0
        public Task <AddNewQuotationResponse> addNewQuotation(AddNewQuotationRequest request)
        {
            AddNewQuotationResponse response = new AddNewQuotationResponse();
            CustomerModel           customer = _customerService.GetByCode(request.customer_code);

            if (customer == null)
            {
                return(Task.FromResult(response));
            }
            AddNewQuotationCommand command = new AddNewQuotationCommand
                                             (
                customer.ID,
                request.date
                                             );
            Task <object> Quotation = (Task <object>)Bus.SendCommand(command);

            //RabbitMQBus.Publish(command);

            response = Common <AddNewQuotationResponse> .checkHasNotification(_notifications, response);

            if (response.Success)
            {
                QuotationModel QuotationModel = (QuotationModel)Quotation.Result;
                response.Data = QuotationModel.ID;
            }
            return(Task.FromResult(response));
        }
Example #9
0
        public async Task Add(SaleViewModel saleViewModel)
        {
            var registerCommand = mapper.Map <CreateSaleCommand>(saleViewModel);

            registerCommand.Items = mapper.Map <List <OrderItem> >(saleViewModel.Items);
            await mediator.SendCommand(registerCommand);
        }
        public async Task <IActionResult> CreateLevantamentoAsync([FromBody] CreateLevantamentoDTO createLevantamento)
        {
            var createLevantamentoCommand = new CreateLevantamentoCommand(createLevantamento.Name, createLevantamento.Description, createLevantamento.Start);
            var result = await _mediator.SendCommand <CreateLeventamentoResponse> (createLevantamentoCommand);

            return(Response(result));
        }
Example #11
0
        public async Task <object> ObterEndereco(string codigoConvite, string numeroCelular)
        {
            var obterEnderecoCommand  = new ObterEnderecoCommand(codigoConvite, numeroCelular);
            var obterEnderecoResponse = await _bus.SendCommand(obterEnderecoCommand);

            return(_notifications.HasNotifications() ? obterEnderecoResponse : _mapper.Map <IEnumerable <EnderecoViewModel> >((IEnumerable <Endereco>)obterEnderecoResponse));
        }
Example #12
0
        public int Register(AddressViewModel addressViewModel)
        {
            var registerCommand = _mapper.Map <RegisterNewAdressCommand>(addressViewModel);

            Bus.SendCommand(registerCommand);
            return(registerCommand.AddressId);
        }
Example #13
0
        public void Create(ProjectModel project)
        {
            // you can use automapper to map source and destination
            var AddNewCommand = new AddNewProjectCommand(project.Name, project.Description, project.IsPrivate, project.OrganizationId);

            _bus.SendCommand(AddNewCommand);
        }
Example #14
0
        public async Task <IActionResult> AddItem(Guid id, int quantity)
        {
            var product = await _productAppService.GetById(id);

            if (product == null)
            {
                return(BadRequest());
            }

            if (product.StockQuantity < quantity)
            {
                TempData["Error"] = "The product has insufficient stock.";
                return(RedirectToAction("ProductDetails", "ShopWindow", new { id }));
            }

            var command = new AddOrderItemCommand(ClientId, product.Id, product.Name, quantity, product.Price);
            await _mediatorHandler.SendCommand(command).ConfigureAwait(true);

            if (IsOperationValid())
            {
                return(RedirectToAction("Index"));
            }

            TempData["Errors"] = GetErrorMessages();
            return(RedirectToAction("ProductDetails", "ShopWindow", new { id }));
        }
Example #15
0
        public async Task <OperationResultVo <Guid> > SaveCourse(Guid currentUserId, CourseViewModel vm)
        {
            int pointsEarned = 0;

            try
            {
                StudyCourse model;

                StudyCourse existing = await mediator.Query <GetCourseByIdQuery, StudyCourse>(new GetCourseByIdQuery(vm.Id));

                if (existing != null)
                {
                    model = mapper.Map(vm, existing);
                }
                else
                {
                    model = mapper.Map <StudyCourse>(vm);
                }

                CommandResult result = await mediator.SendCommand(new SaveCourseCommand(model));

                if (model.Id == Guid.Empty && result.Validation.IsValid)
                {
                    pointsEarned += gamificationDomainService.ProcessAction(currentUserId, PlatformAction.CourseAdd);
                }

                return(new OperationResultVo <Guid>(model.Id, pointsEarned));
            }
            catch (Exception ex)
            {
                return(new OperationResultVo <Guid>(ex.Message));
            }
        }
Example #16
0
        public RegisterConferenceCommand RegisterConference(ConferenceViewModel conferenceViewModel)
        {
            var conference = _mapper.Map <RegisterConferenceCommand>(conferenceViewModel);

            _mediatorHandler.SendCommand(conference);
            return(conference);
        }
        public void Register(CustomerViewModel customerViewModel)
        {
            RegisterNewCustomerCommand registerNewCustomerCommand =
                _mapper.Map <RegisterNewCustomerCommand>(customerViewModel);

            _bus.SendCommand(registerNewCustomerCommand);
        }
        public async Task <ValidationResult> AddAsync(ClienteRegisterViewModel clienteViewModel)
        {
            var registerCommand = _mapper.Map <RegisterClienteCommand>(clienteViewModel);
            var command         = await _mediator.SendCommand(registerCommand);

            return(command);
        }
        private async Task <AccountDetail> GetAccountDetail(long id)

        {
            var tAccount = _redis.GetAccountInfo(id);
            var tMoney   = _moneyClient.GetResponseExt <GetMoneyMqCommand, BodyResponse <MoneyMqResponse> >
                               (new GetMoneyMqCommand(id));

            var tLevel = _bus.SendCommand(new GetLevelInfoCommand(id));
            var tGame  = _bus.SendCommand(new GetGameInfoCommand(id));
            await Task.WhenAll(tAccount, tMoney, tLevel, tGame);

            var accountInfo  = tAccount.Result;
            var moneyInfores = tMoney.Result;
            var moneyInfo    = new MoneyInfo(moneyInfores.Message.Body.CurCoins + moneyInfores.Message.Body.Carry, moneyInfores.Message.Body.CurDiamonds,
                                             moneyInfores.Message.Body.MaxCoins, moneyInfores.Message.Body.MaxDiamonds);
            var levelInfo = tLevel.Result.Body;
            var gameInfo  = tGame.Result.Body;

            if (accountInfo == null || moneyInfo == null || levelInfo == null || gameInfo == null)
            {
                return(null);
            }
            return(new AccountDetail(accountInfo.Id, accountInfo.PlatformAccount,
                                     accountInfo.UserName, accountInfo.Sex, accountInfo.HeadUrl,
                                     accountInfo.Type, levelInfo, gameInfo, moneyInfo));
        }
Example #20
0
        public async Task FinishLoan(int id, FinishLoanDTO loan)
        {
            var finishCommand = _Mapper.Map <FinishLoanCommand>(loan);

            finishCommand.LoanId = id;
            await _Bus.SendCommand(finishCommand);
        }
        public async Task <AddResultViewModel <Guid> > Add(BuildingAddViewModel buildingViewModel)
        {
            var addCommand = _mapper.Map <BuildingAddCommand>(buildingViewModel);
            var result     = await Bus.SendCommand(addCommand);

            return(new AddResultViewModel <Guid>(result, addCommand.Id));
        }
Example #22
0
        public async Task <WrappedResponse <AccountResponseVm> > Login(AccountInfoVm accountInfo)
        {
            var response = await _bus.SendCommand(new LoginCommand(_mapper.Map <AccountInfo>(accountInfo)));

            AccountResponseVm responseVM = _mapper.Map <AccountResponseVm>(response.Body);

            return(new WrappedResponse <AccountResponseVm>(response.ResponseStatus, response.ErrorInfos, responseVM));
        }
Example #23
0
        public async Task Register(DriverViewModel driverViewModel)
        {
            var coordinatesResults = await _gMapsAppService.GetCoordinates(driverViewModel.Address);

            driverViewModel.Coordinates = coordinatesResults.Coordinates;
            var registerCommand = _mapper.Map <RegisterNewDriverCommand>(driverViewModel);
            await Bus.SendCommand(registerCommand);
        }
Example #24
0
        public void Remove(Guid id)
        {
            var command = new DeleteSongCommnad {
                Id = id
            };

            _bus.SendCommand(command);
        }
Example #25
0
        public bool Create(ArticleDto articleDto)
        {
            //var article = _mapper.Map<Article>(articleDto);
            var addCmd = _mapper.Map <ArticleAddCommand>(articleDto);

            _bus.SendCommand <ArticleAddCommand>(addCmd);
            return(_notificationHandler.HasDomainErrors());
        }
Example #26
0
        public async Task Add(SuperheroViewModel superhero)
        {
            var username = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Name).Value;

            superhero.Username = username;
            var registerCommand = _mapper.Map <RegisterSuperheroCommand>(superhero);
            await _bus.SendCommand(registerCommand);
        }
Example #27
0
        public async Task ChangePwd(UserEditViewModel userViewModel)
        {
            var EditCommand = _Mapper.Map <UserChangePwdCommand>(userViewModel);

            await _Bus.SendCommand(EditCommand);

            return;
        }
Example #28
0
        public async Task <IActionResult> Register(UserRegisterView userRegister)
        {
            var command = new CreateNewUserCommand(userRegister.IdentityNumber, userRegister.Name, userRegister.Email, userRegister.Email, userRegister.Password);

            var result = await _mediator.SendCommand <CreateNewUserCommand, ValidationResult>(command).ConfigureAwait(false);

            return(CustomResponse <ValidationResult>(result));
        }
Example #29
0
        public async Task <BodyResponse <AccountResponseVM> > Login(AccountVM accountViewModel)
        {
            var response = await _bus.SendCommand(new LoginCommand(_mapper.Map <AccountInfo>(accountViewModel)));

            AccountResponseVM responseVM = _mapper.Map <AccountResponseVM>(response.Body);

            return(new BodyResponse <AccountResponseVM>(response.StatusCode, response.ErrorInfos, responseVM));
        }
Example #30
0
        public Task <CommandResult> AddOrUpdate(EmpresaViewModel viewModel)
        {
            var command = new AddOrUpdateEmpresaCommand(viewModel.Id, viewModel.RazaoSocial, viewModel.NomeFantasia, viewModel.Descricao);

            command.AttachContato(viewModel.ContatoCelular, viewModel.ContatoEmail, viewModel.ContatoTelefoneComercial, viewModel.ContatoTelefoneResidencial, viewModel.ContatoObservacao);
            command.AttachEndereco(viewModel.EnderecoNumero, viewModel.EnderecoRua, viewModel.EnderecoBairro, viewModel.EnderecoComplemento, viewModel.EnderecoCidadeId, viewModel.EnderecoCEP);
            command.AttachDocumento(viewModel.DocumentoCadastroNacional, viewModel.DocumentoCadastroEstadual);

            return(_mediator.SendCommand(command));
        }