Beispiel #1
0
            public async Task Succeed_With_Valid_Request()
            {
                var command = new DeleteAccountCommand()
                {
                    Id = 1
                };

                var unitOfWork = new Mock <IWriteOnlyUnitOfWork>();
                var repo       = new Mock <IRepository>();

                repo.Setup(p => p.UnitOfWork).Returns(unitOfWork.Object);

                var account = new Account(
                    new AccountId(1),
                    new AccountHolder(
                        new FirstName("Ben"),
                        new LastName("Kennedy")));

                repo.Setup(p => p.FindAsync(It.IsAny <IScalar <Account> >())).ReturnsAsync(account);

                var sut = new DeleteAccountHandler(repo.Object);

                await sut.Handle(command, new CancellationToken());

                repo.Verify(p => p.FindAsync(It.IsAny <IScalar <Account> >()), Times.Once());
                unitOfWork.Verify(p => p.Remove(It.IsAny <Account>()), Times.Once());
                unitOfWork.Verify(p => p.CommitAsync(), Times.Once());
            }
Beispiel #2
0
        public async Task HandleAsync_Should_Delete_Account()
        {
            var deleteAccountCommand = new DeleteAccountCommand(Guid.NewGuid());
            var account = Account.Builder()
                          .SetId(deleteAccountCommand.AccountId)
                          .SetEmail("*****@*****.**")
                          .SetConfirmed(true)
                          .SetPasswordHash("PasswordHash")
                          .SetSecurityStamp(Guid.NewGuid())
                          .SetCreated(DateTimeOffset.UtcNow)
                          .SetRoles(new List <Guid> {
                Guid.NewGuid()
            })
                          .Build();
            var getAccountResult = GetResult <Account> .Ok(account);

            var cancellationToken = new CancellationToken();

            _accountGetterServiceMock.Setup(x => x.GetByIdAsync(It.IsAny <Guid>())).ReturnsAsync(getAccountResult);
            _communicationBusMock.Setup(x => x.DispatchDomainEventsAsync(It.IsAny <Account>(), It.IsAny <CancellationToken>()))
            .Returns(Task.CompletedTask);
            _accountDataConsistencyServiceMock.Setup(x => x.DeleteAccountWithRelatedPersistedGrants(It.IsAny <Account>())).Returns(Task.CompletedTask);
            _integrationEventBusMock.Setup(x => x.PublishIntegrationEventAsync(It.IsAny <IIntegrationEvent>())).Returns(Task.CompletedTask).Verifiable();

            Func <Task> result = async() => await _commandHandler.HandleAsync(deleteAccountCommand, cancellationToken);

            await result.Should().NotThrowAsync <Exception>();

            _communicationBusMock.Verify(
                x => x.DispatchDomainEventsAsync(It.Is <Account>(a => a == account),
                                                 It.Is <CancellationToken>(ct => ct == cancellationToken)), Times.Once);
            _integrationEventBusMock
            .Verify(x => x.PublishIntegrationEventAsync(It.Is <IIntegrationEvent>(ie => ie.CorrelationId == deleteAccountCommand.CorrelationId)));
        }
Beispiel #3
0
        public async Task <IActionResult> DeleteAccount([FromRoute] Guid id)
        {
            var command = new DeleteAccountCommand(id);
            await _bus.Send(command);

            return(NoContent());
        }
Beispiel #4
0
        public async Task <APIResult> Delete([FromBody] DeleteAccountCommand command)
        {
            var rs = await mediator.Send(command);

            return(new APIResult()
            {
                Result = rs
            });
        }
Beispiel #5
0
        public async Task <OkResult> Delete()
        {
            var userId  = Guid.Parse(this.User.Claims.Single(x => x.Type == "http://schemas.microsoft.com/identity/claims/objectidentifier").Value);
            var command = new DeleteAccountCommand(userId);

            await this.mediator.Send(command);

            return(this.Ok());
        }
Beispiel #6
0
        public async Task<IActionResult> Delete(Guid id)
        {
            DeleteAccountCommand deleteAccount = new DeleteAccountCommand() { Id=Guid.NewGuid(), AccountId = id };
            var token = this.Request.Headers["Authorization"].ToString().Substring("Bearer ".Length);

            await _Bus.SendAsync(Queues.Frontend.Commands, token, deleteAccount);

            return Ok();
        }
Beispiel #7
0
        private AccountItemViewModel CreateAccountItem(GitHubAccount githubAccount)
        {
            var viewModel = new AccountItemViewModel(githubAccount);

            viewModel.Selected = Equals(githubAccount, ActiveAccount);
            viewModel.DeleteCommand.Subscribe(_ => DeleteAccountCommand.ExecuteIfCan(githubAccount));
            viewModel.GoToCommand.Subscribe(_ => LoginCommand.ExecuteIfCan(githubAccount));
            return(viewModel);
        }
Beispiel #8
0
        public async Task <ICommandResult> Delete(long id)
        {
            var command = new DeleteAccountCommand
            {
                Id = id
            };
            ICommandResult result = await _handler.Handle(command);

            return(result);
        }
Beispiel #9
0
        public void Handle(DeleteAccountCommand message)
        {
            var aggregate = this.Repository.GetById <AccountDomainModel>(message.Id);

            aggregate.DeleteAccount();

            // here we are sending the aggregate to the NEventStore
            // to serialize the current state or current delta
            this.Repository.Save(aggregate);
        }
        public void TestDeleteAccountActionExecute()
        {
            using (var testDbInfo = SetupUtil.CreateTestDb())
            {
                //Arrange
                Mock <ILog>            mockLog          = new Mock <ILog>();
                AccountRepository      repo             = new AccountRepository(testDbInfo.ConnectionString, mockLog.Object);
                AccountStateRepository accountStateRepo = new AccountStateRepository(testDbInfo.ConnectionString, mockLog.Object);
                RepositoryBag          repositories     = SetupUtil.CreateMockRepositoryBag(testDbInfo.ConnectionString, mockLog.Object, repo, accountStateRepo);

                AccountDto accountDto = new AccountDto()
                {
                    AccountKind = Data.Enums.AccountKind.Sink,
                    CategoryId  = null,
                    Description = "test account",
                    Name        = "Test Account",
                    Priority    = 5
                };
                bool isInsertSuccessful = repo.Upsert(accountDto);
                long accountId          = accountDto.Id.Value;

                int             accountCountBeforeDelete = repo.GetAll().Count();
                AccountStateDto stateDto = new AccountStateDto()
                {
                    AccountId = accountId,
                    Funds     = 0,
                    Timestamp = DateTime.Now,
                    IsClosed  = false
                };
                isInsertSuccessful &= accountStateRepo.Upsert(stateDto);
                int stateCountBeforeDelete = accountStateRepo.GetAll().Count();


                DeleteAccountCommand action = new DeleteAccountCommand("rm account \"Test Account\"", repositories);
                action.AccountName.SetData("Test Account");
                action.IsRecursiveOption.SetData(false);

                //Act
                bool successful = action.TryExecute(mockLog.Object);

                int accountCountAfterDelete = repo.GetAll().Count();
                int stateCountAfterDelete   = accountStateRepo.GetAll().Count();

                bool isClosed = accountStateRepo.GetLatestByAccountId(accountId).IsClosed;

                //Assert
                Assert.True(isInsertSuccessful);
                Assert.True(successful);
                Assert.Equal(1, accountCountBeforeDelete);
                Assert.Equal(1, accountCountAfterDelete);
                Assert.Equal(1, stateCountBeforeDelete);
                Assert.Equal(2, stateCountAfterDelete);
                Assert.True(isClosed);
            }
        }
Beispiel #11
0
        public async Task should_delete_account()
        {
            await RunAsNewUserAsync();

            Account account = An.Account.WithCurrency(A.Currency);
            var     command = new DeleteAccountCommand(account.Id);

            await SendAsync(command);

            (await FindAsync <Account>(account.Id)).Should().BeNull();
        }
Beispiel #12
0
        public async Task <IActionResult> DeleteAccount(int accountId)
        {
            var command = new DeleteAccountCommand(accountId);
            var result  = await Mediator.Send(command);

            if (result)
            {
                return(NoContent());
            }

            throw new Exception("Error deleting the account.");
        }
Beispiel #13
0
        public async Task <IActionResult> DeleteAccount(int id)
        {
            var deleteAccountCommand = new DeleteAccountCommand(id);
            var foundAndDeleted      = await _mediator.Send(deleteAccountCommand);

            if (!foundAndDeleted)
            {
                return(NotFound());
            }

            return(Ok());
        }
        public async Task <Result <bool> > Handle(DeleteAccountCommand request, CancellationToken cancellationToken)
        {
            try
            {
                await _accountRepository.Delete(request.Id);

                return(Result <bool> .Ok(true));
            }
            catch (Exception e)
            {
                return(Result <bool> .Failure(e.Message));
            }
        }
        public async Task <IActionResult> Delete(string id)
        {
            var command = new DeleteAccountCommand(id);
            var result  = await _mediator.Send(command);

            if (result)
            {
                _logger.LogInformation("Account " + id + " was deleted");
                return(NoContent());
            }

            return(NotFound());
        }
Beispiel #16
0
        public async Task should_delete_account_by_another_user_in_the_same_workspace()
        {
            var baseContext = await RunAsNewUserAsync();

            Account account = An.Account.WithCurrency(A.Currency);

            await RunAsNewUserAsync(baseContext.Workspace);

            var command = new DeleteAccountCommand(account.Id);

            await SendAsync(command);

            (await FindAsync <Account>(account.Id)).Should().BeNull();
        }
        public async Task <AccountCommandResult> Handle(DeleteAccountCommand command)
        {
            Account account = await _accountRepository.GetById(command.Id);

            if (account == null)
            {
                AddNotification("command", Messages.Account_NOT_FOUND);
                return(null);
            }

            await _accountRepository.Delete(account);

            return(account.ToDto());
        }
            public async Task Returns_NoContent_With_Valid_Request()
            {
                var mediator = new Mock <IMediator>();

                var command = new DeleteAccountCommand()
                {
                    Id = 1
                };

                var sut = new AccountsController(mediator.Object);

                var result = await sut.Delete(command) as NoContentResult;

                Assert.True(result != null);
            }
Beispiel #19
0
        public async Task <IActionResult> DeleteAccountAsync([FromRoute] Guid id)
        {
            var authResult = await _authorizationService.AuthorizeAsync(User, id, ResourceOwnerPolicy.ResourceOwnerPolicyName);

            if (!authResult.Succeeded)
            {
                return(CreateErrorResult(HttpStatusCode.Forbidden));
            }

            var deleteAccountCommand = new DeleteAccountCommand(id);
            await _communicationBus.SendCommandAsync(deleteAccountCommand);

            Response.Headers.Add(HeaderNameConstants.XCorrelationId, deleteAccountCommand.CorrelationId.ToString());
            return(Accepted());
        }
Beispiel #20
0
        public AccountsViewModel(IAccountsService accountsService)
        {
            _accountsService = accountsService;

            Title = "Accounts";

            _accounts = new ReactiveList <GitHubAccount>(accountsService.OrderBy(x => x.Username));
            this.WhenActivated(d => _accounts.Reset(accountsService.OrderBy(x => x.Username)));
            Accounts = _accounts.CreateDerivedCollection(CreateAccountItem);

            this.WhenAnyValue(x => x.ActiveAccount)
            .Subscribe(x =>
            {
                foreach (var account in Accounts)
                {
                    account.Selected = account.Id == x.Key;
                }
            });

            DeleteAccountCommand = ReactiveCommand.Create();
            DeleteAccountCommand.OfType <GitHubAccount>().Subscribe(x =>
            {
                if (Equals(accountsService.ActiveAccount, x))
                {
                    ActiveAccount = null;
                }
                accountsService.Remove(x);
                _accounts.Remove(x);
            });

            LoginCommand = ReactiveCommand.Create();
            LoginCommand.OfType <GitHubAccount>().Subscribe(x =>
            {
                if (!Equals(accountsService.ActiveAccount, x))
                {
                    ActiveAccount = x;
                    MessageBus.Current.SendMessage(new LogoutMessage());
                }

                Dismiss();
            });

            DismissCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.ActiveAccount)
                                                    .Select(x => x != null)).WithSubscription(x => Dismiss());

            GoToAddAccountCommand = ReactiveCommand.Create()
                                    .WithSubscription(_ => NavigateTo(this.CreateViewModel <NewAccountViewModel>()));
        }
Beispiel #21
0
        public async Task <ICommandResult> Handle(DeleteAccountCommand command)
        {
            Account account = await _accountRepository.GetById(command.Id);

            if (account == null)
            {
                return(new CommandResult(false, Messages.Account_NOT_FOUND, null));
            }

            await _accountRepository.Delete(account);

            return(new CommandResult(
                       true,
                       Messages.DELETED_WITH_SUCCESS,
                       null));
        }
Beispiel #22
0
        public async Task HandleAsync_Should_Throw_ResourceNotFoundException_When_Account_Is_Not_Found()
        {
            var deleteAccountCommand = new DeleteAccountCommand(Guid.NewGuid());
            var errors = new Collection <IError>
            {
                new Error(AccountErrorCodeEnumeration.NotFound, AccountErrorMessage.NotFound)
            };
            var getAccountResult = GetResult <Account> .Fail(errors);

            _accountGetterServiceMock.Setup(x => x.GetByIdAsync(It.IsAny <Guid>())).ReturnsAsync(getAccountResult);

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

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

            exceptionResult.And.Errors.Should().BeEquivalentTo(errors);
        }
        public void DeleteAccountCommand()
        {
            using (var testDbInfo = SetupUtil.CreateTestDb())
            {
                Mock <ILog> mockLog = new Mock <ILog>();

                CommandInterpreter interpreter = new CommandInterpreter(SetupUtil.CreateMockRepositoryBag(testDbInfo.ConnectionString, mockLog.Object), BudgetCliCommands.BuildCommandLibrary());

                ICommandAction action;
                bool           success = interpreter.TryParseCommand("rm account test", out action);

                Assert.True(success);
                Assert.IsType <DeleteAccountCommand>(action);

                DeleteAccountCommand deleteAccount = (DeleteAccountCommand)action;
                Assert.Equal("test", deleteAccount.AccountName.GetValue(null));
            }
        }
Beispiel #24
0
        public async Task DeleteAccount_Failures()
        {
            var userName = "******";

            TestDataInitializer.CreateUser(userName);

            var user = TestHelper.SetPrincipal(userName);
            //username doesnt match
            var cmd = new DeleteAccountCommand(
                new Domain.Models.DeleteAccountOptions()
            {
                UserName        = userName,
                ConfirmUserName = "******"
            });
            var result = await cmd.Execute();

            Assert.IsFalse(result.Success, result.Message);

            //password doesn't match
            cmd = new DeleteAccountCommand(
                new Domain.Models.DeleteAccountOptions()
            {
                UserName        = userName,
                ConfirmUserName = userName,
                CurrentPassword = "******"
            });
            result = await cmd.Execute();

            Assert.IsFalse(result.Success, result.Message);

            //wrong user
            user = TestHelper.SetPrincipal("TestUser01");

            cmd = new DeleteAccountCommand(
                new Domain.Models.DeleteAccountOptions()
            {
                UserName        = userName,
                ConfirmUserName = userName,
                CurrentPassword = userName
            });
            result = await cmd.Execute();

            Assert.IsFalse(result.Success, result.Message);
        }
        public async Task <IActionResult> Delete(long id)
        {
            try
            {
                var command = new DeleteAccountCommand
                {
                    Id = id
                };
                _uow.OpenTransaction();

                var result = await _handler.Handle(command);

                return(await Response(result, _handler.Notifications));
            }
            catch (Exception ex)
            {
                return(await TryErrors(ex));
            }
        }
        private ICommandAction BuildRemoveAccountCommand(string input, CommandUsageMatchData matchData)
        {
            DeleteAccountCommand cmd = new DeleteAccountCommand(input, Repositories);

            string accountName;

            if (!matchData.TryGetArgValue(BudgetCliCommands.ARG_ACCOUNT_NAME, out accountName))
            {
                return(null);
            }

            cmd.AccountName.SetData(accountName);

            if (matchData.HasToken(BudgetCliCommands.OPT_RECURSIVE))
            {
                cmd.IsRecursiveOption.SetData(true);
            }

            return(cmd);
        }
        public IActionResult DeleteAccount(int accountId)
        {
            if (accountId == null)
            {
                return(BadRequest());
            }

            try
            {
                var command = new DeleteAccountCommand(accountId);

                var commandHandler = new AccountCommandHandler(_accountRepository);

                commandHandler.Handle(command);

                return(Ok());
            }
            catch (CommandValidationException <eAccountError> ex)
            {
                return(BadRequest(ex.Error.ToString()));
            }
        }
Beispiel #28
0
 public Task DeleteAccount(DeleteAccountCommand command, CancellationToken token)
 => HandlerDispatcher.Invoke <DeleteAccountHandler, DeleteAccountCommand>(command, token);
Beispiel #29
0
        public async Task DeleteAccount_Basic()
        {
            //EnsureBadges
            using (var db = new VoatDataContext())
            {
                if (!db.Badge.Any(x => x.ID == "deleted"))
                {
                    db.Badge.Add(new Badge()
                    {
                        ID = "deleted", Name = "Account Deleted", Graphic = "deleted.png", Title = "deleted"
                    });
                }
                if (!db.Badge.Any(x => x.ID == "deleted2"))
                {
                    db.Badge.Add(new Badge()
                    {
                        ID = "deleted2", Name = "Account Deleted", Graphic = "deleted2.png", Title = "deleted"
                    });
                }
                if (!db.Badge.Any(x => x.ID == "donor_upto_30"))
                {
                    db.Badge.Add(new Badge()
                    {
                        ID = "donor_upto_30", Name = "Donor Up To Thirty", Graphic = "donor30.png", Title = "Donor"
                    });
                }


                db.SaveChanges();
            }


            var userName = "******";

            TestDataInitializer.CreateUser(userName);
            var user = TestHelper.SetPrincipal(userName);
            DeleteAccountCommand cmd;
            CommandResponse      result;

            var options = new Domain.Models.DeleteAccountOptions()
            {
                UserName        = userName,
                ConfirmUserName = userName,
                CurrentPassword = userName,
                Comments        = Domain.Models.DeleteOption.Anonymize,
                LinkSubmissions = Domain.Models.DeleteOption.Anonymize,
                TextSubmissions = Domain.Models.DeleteOption.Anonymize
            };

            var submission = TestHelper.ContentCreation.CreateSubmission(options.UserName, new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit,
                Title    = "Test Submission Yeah",
                Content  = "Test Submission Content"
            });

            var comment = TestHelper.ContentCreation.CreateComment(options.UserName, submission.ID, "This is a test comment");

            //Anon it all
            cmd    = new DeleteAccountCommand(options).SetUserContext(user);
            result = await cmd.Execute();

            VoatAssert.IsValid(result);
            VerifyDelete(options);


            userName = "******";

            TestDataInitializer.CreateUser(userName);
            user = TestHelper.SetPrincipal(userName);

            using (var db = new VoatDataContext())
            {
                //Trying to trap a bug with a user not getting delete badge
                db.UserBadge.Add(new Voat.Data.Models.UserBadge()
                {
                    BadgeID = "donor_upto_30", CreationDate = DateTime.UtcNow, UserName = userName
                });
                db.SaveChanges();
            }

            options = new Domain.Models.DeleteAccountOptions()
            {
                UserName        = userName,
                ConfirmUserName = userName,
                CurrentPassword = userName,
                Comments        = Domain.Models.DeleteOption.Delete,
                LinkSubmissions = Domain.Models.DeleteOption.Delete,
                TextSubmissions = Domain.Models.DeleteOption.Delete
            };

            submission = TestHelper.ContentCreation.CreateSubmission(options.UserName, new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit,
                Title    = "Test Submission Yeah",
                Content  = "Test Submission Content"
            });

            comment = TestHelper.ContentCreation.CreateComment(options.UserName, submission.ID, "This is a test comment");

            //Delete
            cmd    = new DeleteAccountCommand(options).SetUserContext(user);
            result = await cmd.Execute();

            VoatAssert.IsValid(result);

            VerifyDelete(options);



            userName = "******";

            TestDataInitializer.CreateUser(userName);
            user = TestHelper.SetPrincipal(userName);

            //Need to ensure delete clears preferences
            var prefUpdate = new UpdateUserPreferencesCommand(new Domain.Models.UserPreferenceUpdate()
            {
                Bio = "My Bio"
            }).SetUserContext(user);
            var p = await prefUpdate.Execute();

            VoatAssert.IsValid(p);

            using (var db = new VoatDataContext())
            {
                var prefs = db.UserPreference.FirstOrDefault(x => x.UserName == userName);
                Assert.IsNotNull(prefs, "Expected user to have preference record at this stage");
                prefs.Avatar = userName + ".jpg";

                //Add badges to prevent duplicates
                db.UserBadge.Add(new Voat.Data.Models.UserBadge()
                {
                    BadgeID = "deleted", CreationDate = DateTime.UtcNow, UserName = userName
                });
                db.UserBadge.Add(new Voat.Data.Models.UserBadge()
                {
                    BadgeID = "deleted2", CreationDate = DateTime.UtcNow, UserName = userName
                });

                db.SaveChanges();
            }

            options = new Domain.Models.DeleteAccountOptions()
            {
                UserName                    = userName,
                ConfirmUserName             = userName,
                CurrentPassword             = userName,
                Comments                    = Domain.Models.DeleteOption.Delete,
                LinkSubmissions             = Domain.Models.DeleteOption.Delete,
                TextSubmissions             = Domain.Models.DeleteOption.Delete,
                RecoveryEmailAddress        = "*****@*****.**",
                ConfirmRecoveryEmailAddress = "*****@*****.**",
                Reason = "I need a break from the racialists"
            };

            submission = TestHelper.ContentCreation.CreateSubmission(options.UserName, new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit,
                Title    = "Test Submission Yeah",
                Content  = "Test Submission Content"
            });

            comment = TestHelper.ContentCreation.CreateComment(options.UserName, submission.ID, "This is a test comment");

            //Delete
            cmd    = new DeleteAccountCommand(options).SetUserContext(user);
            result = await cmd.Execute();

            VoatAssert.IsValid(result);
            VerifyDelete(options);
        }
        public ProfileViewModel(IParentService parentService, IUserDialogs userDialogs,
                                IMvxMessenger mvxMessenger, AppHelper appHelper) : base(userDialogs, mvxMessenger, appHelper)
        {
            _parentService = parentService;

            SaveChangesCommand = ReactiveCommand.CreateFromObservable <Unit, ParentEntity>((param) =>
            {
                return(NewProfileImage != null ?
                       _parentService.UploadProfileImage(NewProfileImage.GetStream())
                       .SelectMany((_) => _parentService.Update(SelfParent.FirstName, SelfParent.LastName, SelfParent.Birthdate, SelfParent.Email, string.Concat(SelfParent.PhonePrefix, SelfParent.PhoneNumber))) :

                       _parentService.Update(SelfParent.FirstName, SelfParent.LastName, SelfParent.Birthdate, SelfParent.Email, string.Concat(SelfParent.PhonePrefix, SelfParent.PhoneNumber)));
            });


            SaveChangesCommand.Subscribe(AccountUpdatedHandler);

            SaveChangesCommand.IsExecuting.Subscribe((IsLoading) => HandleIsExecuting(IsLoading, AppResources.Profile_Save_Changes));

            SaveChangesCommand.ThrownExceptions.Subscribe(HandleExceptions);

            RefreshCommand = ReactiveCommand.CreateFromObservable <Unit, ParentEntity>((param) => _parentService.GetProfileInformation());

            RefreshCommand.Subscribe((ParentEntity) => {
                SelfParent.HydrateWith(ParentEntity);
                ResetCommonProps();
                IsDirtyMonitoring = true;
            });

            RefreshCommand.IsExecuting.Subscribe((IsLoading) => HandleIsExecuting(IsLoading, AppResources.Profile_Loading_Data));

            RefreshCommand.ThrownExceptions.Subscribe(HandleExceptions);

            DeleteAccountCommand = ReactiveCommand
                                   .CreateFromObservable <Unit, string>((param) =>
            {
                return(Observable.FromAsync <bool>((_) => _userDialogs.ConfirmAsync(new ConfirmConfig()
                {
                    Title = AppResources.Profile_Confirm_Account_Deleting
                })).Where((confirmed) => confirmed).Do((_) => HandleIsExecuting(true, AppResources.Profile_Account_Deleting))
                       .SelectMany((_) => _parentService.DeleteAccount())
                       .Do((_) => HandleIsExecuting(false, AppResources.Profile_Account_Deleting)));
            });


            DeleteAccountCommand.Subscribe((_) =>
            {
                Bullytect.Core.Config.Settings.AccessToken = null;
                ShowViewModel <AuthenticationViewModel>(new AuthenticationViewModel.AuthenticationParameter()
                {
                    ReasonForAuthentication = AuthenticationViewModel.ACCOUNT_DELETED
                });
            });


            DeleteAccountCommand.ThrownExceptions.Subscribe(HandleExceptions);


            TakePhotoCommand = ReactiveCommand.CreateFromObservable <Unit, MediaFile>((_) => appHelper.PickPhotoStream());


            TakePhotoCommand.Subscribe((ImageStream) => {
                _userDialogs.HideLoading();
                NewProfileImage = ImageStream;
                OnNewSelectedImage(ImageStream);
            });

            TakePhotoCommand.ThrownExceptions.Subscribe(HandleExceptions);
        }