Exemplo n.º 1
0
        public async Task <IActionResult> DeleteStateAsync([FromRoute] Guid id, [FromHeader(Name = "If-Match")] byte[] rowVersion)
        {
            var deleteStateCommand = new DeleteStateCommand(id, rowVersion);
            await _communicationBus.SendCommandAsync(deleteStateCommand);

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> DELETE_STATE([FromBody] DeleteStateCommand command)
        {
            var res = await _mediator.Send(command);

            if (!res.Status.IsSuccessful)
            {
                return(BadRequest(res));
            }
            return(Ok(res));
        }
Exemplo n.º 3
0
 public void DeleteState(int itemindex, int keyindex)
 {
     try
     {
         var be   = canvasDock.EffectManager.Effects[itemindex] as BaseEffect;
         var name = Path.GetFileNameWithoutExtension(be.Filename);
         var dsc  = new DeleteStateCommand(canvasDock.EffectManager, deletestate + name, itemindex, keyindex);
         dsc.Execute();
         historyDock.CommandManager.AddCommand(dsc);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Exemplo n.º 4
0
        public async Task HandleAsync_Should_Throw_PreconditionFailedException_When_RowVersion_Does_Not_Match()
        {
            var command = new DeleteStateCommand(Guid.NewGuid(), new byte[] { 1, 2, 4, 8, 16, 64 });
            var state   = State.Builder()
                          .SetId(command.StateId)
                          .SetRowVersion(new byte[] { 1, 2, 4, 8, 16, 32 })
                          .SetName("Name")
                          .SetPolishName("PolishName")
                          .Build();
            var getStateResult = GetResult <State> .Ok(state);

            _stateGetterServiceMock.Setup(x => x.GetByIdAsync(It.IsAny <Guid>())).ReturnsAsync(getStateResult);

            Func <Task> result = async() => await _commandHandler.HandleAsync(command);

            await result.Should().ThrowAsync <PreconditionFailedException>();
        }
Exemplo n.º 5
0
        public async Task HandleAsync_Should_Throw_ResourceNotFoundException_When_State_Is_Not_Found()
        {
            var command = new DeleteStateCommand(Guid.NewGuid(), new byte[] { 1, 2, 4, 8, 16, 32, 64 });
            var errors  = new Collection <IError>
            {
                new Error(StateErrorCodeEnumeration.NotFound, StateErrorMessage.NotFound)
            };
            var getStateResult = GetResult <State> .Fail(errors);

            _stateGetterServiceMock.Setup(x => x.GetByIdAsync(It.IsAny <Guid>())).ReturnsAsync(getStateResult);

            Func <Task> result = async() => await _commandHandler.HandleAsync(command);

            var exceptionResult = await result.Should().ThrowAsync <ResourceNotFoundException>();

            exceptionResult.And.Errors.Should().BeEquivalentTo(errors);
        }
Exemplo n.º 6
0
        public async Task HandleAsync_Should_Delete_State()
        {
            var command = new DeleteStateCommand(Guid.NewGuid(), Array.Empty <byte>());
            var state   = State.Builder()
                          .SetId(command.StateId)
                          .SetRowVersion(command.RowVersion)
                          .SetName("Name")
                          .SetPolishName("PolishName")
                          .Build();
            var getStateResult = GetResult <State> .Ok(state);

            _stateGetterServiceMock.Setup(x => x.GetByIdAsync(It.IsAny <Guid>())).ReturnsAsync(getStateResult);
            _stateRepositoryMock.Setup(x => x.DeleteAsync(It.IsAny <State>())).Returns(Task.CompletedTask);

            Func <Task> result = async() => await _commandHandler.HandleAsync(command);

            await result.Should().NotThrowAsync <Exception>();
        }
 // Run 'CanExecute' for all buttons
 private void RunAllCanExecute()
 {
     NewStateCommand.RaiseCanExecuteChanged();
     UpdateStateCommand.RaiseCanExecuteChanged();
     DeleteStateCommand.RaiseCanExecuteChanged();
 }