public long Create(CreateAuctionCommand command) { long createdId = 0; _listener.Subscribe(new ActionEventHandler <AuctionOpened>(a => createdId = a.Id)); _bus.Dispatch(command); return(createdId); }
public ActionResult Save(CreateInvoiceSaleCommand model) { model.Children.Add(new InvoiceSaleChild(0, 100, 1, 2000)); model.Children.Add(new InvoiceSaleChild(0, 101, 2, 5000)); Bus.Dispatch(model); return(View()); }
public void Execute(SelectGoodsTypeQuery command, CommandType commandtype, string usersave) { if (command != null) { switch (commandtype) { case CommandType.Create: { var obj = new CreateGoodsTypeCommand() { TypeTitle = command.TypeTitle, ParentId = command.ParentId, UserSave = usersave }; foreach (var itm in command.Goodsgroups) { obj.Goodsgroup.Add(new CreateGoodsGroupCommand() { GoodsTypeId = itm.Id, GroupTitle = itm.GroupTitle, ParentId = itm.ParentId }); } _bus.Dispatch(obj); break; } case CommandType.Update: { var obj = new UpdateGoodsTypeCommand() { Id = command.Id, TypeTitle = command.TypeTitle, ParentId = command.ParentId, UserSave = usersave }; _bus.Dispatch(obj); break; } case CommandType.Delete: { var obj = new DeleteGoodsTypeCommand() { Id = command.Id, TypeTitle = command.TypeTitle, ParentId = command.ParentId, UserSave = usersave }; _bus.Dispatch(obj); break; } } } }
public async Task Create(EstateViewModel model) { await _bus.Dispatch(new CreateEstateCommand { Address = model.Address, Area = model.Area, Direction = model.Direction, Name = model.Name, OwnerId = model.OwnerId }); }
public async Task <IActionResult> CreateProduct(CreateProductCommand command) { var id = 0; _eventListener.Subscribe(new ActionHandler <EntityCreated>(a => { id = a.Id; })); await _bus.Dispatch(command); return(Ok(id)); }
public void CreateAccount(CreateAccountDto createAccountDto) { commandBus.Dispatch(new CreateAccountCommand() { OwnerId = createAccountDto.OwnerId }); }
public void Dispatch <T>(T command) where T : ICommand { using (_container.BeginScope()) { _commandBus.Dispatch(command); } }
public void DispatchClassCommand() { ICommandBus commandBus = GetCommandBus(); HelloCommand command = new HelloCommand("Felix"); commandBus.Dispatch(command); Assert.AreEqual("Hello Felix", command.Text); }
public void DispatchCreateUserCommand() { ICommandBus commandBus = ComponentContainer.CreateComponent <ICommandBus>(); CreateUserCommand command = new CreateUserCommand("Shiori", "987654321"); commandBus.Dispatch(command); Assert.AreEqual("1234", command.CreateResult); }
public Guid Post(CreateDimensionCommand command) { var id = Guid.Empty; this._listener.Subscribe(new ActionHandler <DimensionCreated>(a => { id = a.Id; })); _commandBus.Dispatch(command); return(id); }
private void RetryDispatch(ICommandMessage commandMessage) { try { _commandBus.Dispatch(commandMessage, this); } catch (Exception e) { OnFailure(commandMessage, e); } }
public Task Handle(PartyConfirmed message, IMessageHandlerContext context) { var command = new CreateParticipantCommand { Id = message.PartyId, Name = message.Name }; _commandBus.Dispatch(command); return(Task.CompletedTask); }
ValueTask IMessageReceiver.Message(DataMessage oDataMessage) { var sCommandName = oDataMessage.Data.Type; var sCommandData = oDataMessage.Data.Attributes; // var oCommandType = _oCommandMapper.GetCommandTypeByName(sCommandName); var oCommand = _oCommandMapper.ToCommand(sCommandName, sCommandData); _oCommandBus.Dispatch(oCommand); return(new ValueTask()); }
public void DispatchMixedInterfaceCommand() { ICommandBus commandBus = GetCommandBus(); for (int i = 1; i < 11; i++) { User user = new User(i, i * 10); commandBus.Dispatch(user); Assert.AreEqual($"UserOf{i}", user.UserName); Assert.AreEqual($"RoleOf{i * 10}", user.RoleName); } }
public async Task <IActionResult> Post(CreateLetterCommand command) { try { var userId = this.User.Claims.FirstOrDefault(x => x.Type == "sub")?.Value; var result = await _bus.Dispatch(command); return(Ok(result)); } catch (Exception e) { return(StatusCode((int)HttpStatusCode.ExpectationFailed, e.Message)); } }
public Guid RegisterCustomer(RegisterCustomerCommand registerCustomerCommand) { Guid customerId = Guid.Empty; eventBus.Subscribe(new ActionHandler <CustomerCreatedEvent>(p => customerId = p.CustomerId )); var opt = new TransactionOptions(); opt.IsolationLevel = IsolationLevel.ReadCommitted; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, opt))//AOP =>use PostSharp Or Castle Interceptor { commandbus.Dispatch(registerCustomerCommand); commandbus.Dispatch(new CreateAccountCommand() { OwnerId = customerId }); scope.Complete(); eventBus.Publish(new TransactionCommitedEvent()); } return(customerId); }
protected IActionResult Dispatch(ICommand command) { try { commandBus.Dispatch(command); return(StatusCode(200)); } catch (System.Exception Exception) { HttpResponse response = (new FailureResponseCreator(Exception)).Create(); object ErrorData = jsonApiEncoder.EncodeError(response); return(StatusCode(response.Code, ErrorData)); } }
public void Create() { ContainerBuilder builder = new ContainerBuilder(); builder .RegisterCommandBusComponents() .RegsiterCommandHandlers(this.GetType().Assembly); var container = builder.Build(); ICommandBus bus = container.Resolve <ICommandBus>(); MyCommand cmd = new MyCommand(); bus.Dispatch(cmd); Assert.AreEqual("A", cmd.AResult); Assert.AreEqual("B", cmd.BResult); }
public HttpResponseMessage PostListing([FromBody] RealtorListing realtorListing) { var listingId = Guid.NewGuid(); var postListing = new PostListing( listingId, realtorListing.NumberOfBathrooms, realtorListing.NumberOfBedrooms, realtorListing.YearBuilt, realtorListing.Street, realtorListing.City, realtorListing.State, realtorListing.Zip, realtorListing.Price); try { _commandBus.Dispatch(postListing); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex)); } return(Request.CreateResponse(HttpStatusCode.Created, postListing)); }
public async Task <ActionResult <Guid> > CreateProductWithReturn([FromServices] ICommandBus commandBus, [FromBody] CreateProductWithReturnCommand command, CancellationToken cancellationToken) { var response = await commandBus.Dispatch(command, cancellationToken); return(Ok(response)); }
public IActionResult CreateStudent(CreateStudentCommand studentVm) { _bus.Dispatch(studentVm); return(View()); }
public IActionResult Add([FromBody] AddAnswer command) { _commandBus.Dispatch(command); return(NoContent()); }
public void Post([ModelBinder(typeof(ProductModelBinder))] CreateGenericProductCommand command) { _commandBus.Dispatch(command); }
public void Post(OpenAuctionCommand command) { _bus.Dispatch(command); }
public IdResponse CreateCategory(CreateCategoryCommand command) { return(_bus.Dispatch <CreateCategoryCommand, IdResponse>(command)); }
public string Post(CreateAccountCommand command) { // eventBus.Subscribe<CustomerCreatedEvent> commandbus.Dispatch(command); return("OK"); }
public void RegisterWine(Model.Dtos.RegisterWine registerWine) { _commandBus.Dispatch(new RegisterWine().From(registerWine)); }
public async Task <IActionResult> CreateProductWithReturn([FromServices] ICommandBus commandBus, [FromBody] CreateProductCommand command, CancellationToken cancellationToken) { await commandBus.Dispatch(command, cancellationToken); return(Ok()); }
public void Post([FromBody] OpenAuctionCommand command) { _bus.Dispatch(command); }
public IActionResult Create([FromBody] CreateQuestion command) { _bus.Dispatch(command); return(NoContent()); }