Пример #1
0
        private void FetchData()
        {
            bool wasSalvatorOn;

            if (DataSalvator.switchedOn)
            {
                DataSalvator.switchedOn = false;
                wasSalvatorOn           = true;
            }
            else
            {
                wasSalvatorOn = false;
            }

            DataSalvator.FlushChanges();
            Model = new DataModel();
            AddEntryCommand.RaiseCanExecuteChanged();

            if (Entries.Count > 0)
            {
                HighlightedEntry = Entries[0];
                IncreaseBookCountCommand.RaiseCanExecuteChanged();
                DecreaseBookCountCommand.RaiseCanExecuteChanged();
                DeleteEntryCommand.RaiseCanExecuteChanged();
            }
            ;
            if (wasSalvatorOn)
            {
                DataSalvator.switchedOn = true;
            }
        }
Пример #2
0
        public async Task Hanlde_DeleteEntryCommand_RemovesEntryFromProjectAsync()
        {
            // arrange
            var project = CreateProject();
            var entryId = project.Configuration.Entities.First().Entries.First().Id;

            var command = new DeleteEntryCommand
            {
                Id      = project.Id,
                EntryId = entryId
            };

            var session = new Mock <ISession>();

            session.Setup(s => s.Get <Project>(project.Id, command.ExpectedVersion, It.IsAny <CancellationToken>())).Returns(Task.FromResult(project));

            var target = new ProjectCommandHandler(session.Object);

            // act
            await target.Handle(command);

            // assert
            var entry = project.Configuration.Entities.First().Entries.FirstOrDefault(e => e.Id == entryId);

            Assert.Null(entry);
            session.Verify(s => s.Commit(It.IsAny <CancellationToken>()));
        }
        public async Task <ActionResult> DeleteEntry([FromBody] DeleteEntryCommand command)
        {
            command.MasterPassword = Request.Headers["masterPassword"];
            var a = await Mediator.Send(command);

            return(Ok(a));
        }
Пример #4
0
        private void AddEntry()
        {
            Entries.Add(DataSalvator.NewEntry());
            HighlightedEntry = Entries[Entries.Count - 1];

            RaisePropertyChanged("Entries");
            RaisePropertyChanged("HighlightedEntry");
            DecreaseBookCountCommand.RaiseCanExecuteChanged();
            DeleteEntryCommand.RaiseCanExecuteChanged();
            ProvideFeedback("An entry added");
        }
Пример #5
0
 public PassinstantVM()
 {
     Entries               = new ObservableCollection <Entry>();
     NewEntryCommand       = new NewEntryCommand(this);
     EditEntryCommand      = new EditEntryCommand(this);
     DeleteEntryCommand    = new DeleteEntryCommand(this);
     GetAccountNameCommand = new GetAccountNameCommand(this);
     GetPasswordCommand    = new GetPasswordCommand(this);
     VMInteractionHandler.PassinstantVM = this;
     UpdateEntries();
 }
        public async Task <IActionResult> DeleteEntryAsync([FromBody] DeleteEntryDto deleteEntryDto)
        {
            var command = new DeleteEntryCommand
            {
                PhoneBookId = deleteEntryDto.PhoneBookId,
                EntryId     = deleteEntryDto.EntryId
            };

            await _mediator.DispatchAsync(command);

            return(Ok());
        }
Пример #7
0
        public async System.Threading.Tasks.Task DeleteEntryCommandHandler_Fail()
        {
            var phoneBook = new PhoneBookAggregateRoot {
                Name = _phoneBookName
            };
            await _phoneBookRepositoryMock.AddAsync(phoneBook);

            var deleteEntryCommandHandler = new DeleteEntryCommandHandler(_phoneBookRepositoryMock);
            var deleteEntryCommand        = new DeleteEntryCommand {
                PhoneBookId = phoneBook.Id, EntryId = Guid.NewGuid()
            };

            await Assert.ThrowsAsync <ValidateException>(() => deleteEntryCommandHandler.HandleAsync(deleteEntryCommand));
        }
Пример #8
0
        public async System.Threading.Tasks.Task DeleteEntryCommandHandler_Success()
        {
            //Given
            var phoneBook = new PhoneBookAggregateRoot {
                Name = _phoneBookName
            };

            phoneBook.InsertEntry("TestUser", "0817810008");
            var entryId = phoneBook.Entries.FirstOrDefault().Id;

            await _phoneBookRepositoryMock.AddAsync(phoneBook);

            var deleteEntryCommandHandler = new DeleteEntryCommandHandler(_phoneBookRepositoryMock);
            var deleteEntryCommand        = new DeleteEntryCommand {
                PhoneBookId = phoneBook.Id, EntryId = entryId
            };

            //When
            await deleteEntryCommandHandler.HandleAsync(deleteEntryCommand);

            //Then
            Assert.Empty(((PhoneBookRepositoryMock)_phoneBookRepositoryMock).phoneBookAggregates.FirstOrDefault().Entries);
        }