Ejemplo n.º 1
0
        public async Task Context()
        {
            _serviceProvider = new ServiceProviderHelper().BuildServiceProvider();
            _serviceScope    = _serviceProvider.CreateScope();

            _unitOfWork = _serviceProvider.GetService <NhibernateUnitOfWork>();
            _unitOfWork.BeginTransaction();

            _newShip = new ShipBuilder().Build();
            _unitOfWork.Save(_newShip);

            var manageShipsController = new ManageShipsControllerBuilder(_serviceProvider).Build();

            var updateShipCommand = new UpdateShipCommand
            {
                ShipId   = _newShip.Id,
                ShipName = "updated ship name",
                Tonnage  = 34.5m
            };

            _actionResult = await manageShipsController.UpdateShip(updateShipCommand);

            _unitOfWork.Flush();
            _unitOfWork.Clear();
        }
Ejemplo n.º 2
0
        public void Context()
        {
            _unitOfWork = new NhibernateUnitOfWork(new CoreDddSharedNhibernateConfigurator());
            _unitOfWork.BeginTransaction();

            var ship = new ShipBuilder().Build();

            _unitOfWork.Save(ship);

            var updateShipCommand = new UpdateShipCommand
            {
                ShipId   = ship.Id,
                ShipName = "updated ship name",
                Tonnage  = 34.5m
            };
            var updateShipCommandHandler = new UpdateShipCommandHandler(new NhibernateRepository <Ship>(_unitOfWork));

#if NET40
            updateShipCommandHandler.Execute(updateShipCommand);
#endif
#if NETCOREAPP
            updateShipCommandHandler.ExecuteAsync(updateShipCommand).Wait();
#endif

            _unitOfWork.Flush();
            _unitOfWork.Clear();

            _updatedShip = _unitOfWork.Get <Ship>(ship.Id);
        }
Ejemplo n.º 3
0
        protected void UpdateShipButton_OnClick(object sender, EventArgs e)
        {
            var updateShipCommand = new UpdateShipCommand
            {
                ShipId   = int.Parse(ShipIdTextBox.Text),
                ShipName = ShipNameTextBox.Text,
                Tonnage  = decimal.Parse(TonnageTextBox.Text)
            };

            _commandExecutor.Execute(updateShipCommand);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> UpdateShip(UpdateShipCommand updateShipCommand)
        {
            await _commandExecutor.ExecuteAsync(updateShipCommand);

            return(RedirectToAction("UpdateShip"));
        }