Ejemplo n.º 1
0
        public bool DeleteAccount(int usuarioId)
        {
            bool result = false;

            using (TransactionScope scope = new TransactionScope())
            {
                IDataQuery query = new DataQuery();
                query.Where = string.Format("userId={0}", usuarioId);
                IList <IProfile> collection = _repositoryProfile.Find(query);
                if (collection.Count > 0)
                {
                    VoteRepository voteRepository = new VoteRepository(_dataBase);
                    query.Where = string.Format("profileId={0}", collection[0].ProfileId);
                    IList <IVote> votes = voteRepository.Find(query);

                    foreach (IVote vote in votes)
                    {
                        voteRepository.Remove(vote.VoteId);
                    }

                    _repositoryProfile.Remove(collection[0].ProfileId);

                    result = _repository.Remove(usuarioId);
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public void Remove_And_Presist_Changes_Should_Succeed()
        {
            using (BeginTransaction())
            {
                var vote = CreateNewStoryVote();
                _database.InsertOnSubmit(vote);
                _database.SubmitChanges();

                _voteRepository.Remove(vote);
                Assert.Equal(EntityState.Deleted, vote.EntityState);
                _database.SubmitChanges();
                Assert.Equal(EntityState.Detached, vote.EntityState);
            }
        }
Ejemplo n.º 3
0
        public bool DeleteAccount(int usuarioId)
        {
            bool result = false;

            using (TransactionScope scope = new TransactionScope())
            {
                IDataQuery query = new DataQuery();
                query.Where = string.Format("userId={0}", usuarioId);
                IList<IProfile> collection = _repositoryProfile.Find(query);
                if (collection.Count > 0)
                {
                    VoteRepository voteRepository = new VoteRepository(_dataBase);
                    query.Where = string.Format("profileId={0}", collection[0].ProfileId);
                    IList<IVote> votes = voteRepository.Find(query);

                    foreach (IVote vote in votes)
                    {
                        voteRepository.Remove(vote.VoteId);
                    }

                    _repositoryProfile.Remove(collection[0].ProfileId);

                    result = _repository.Remove(usuarioId);
                }
            }

            return result;
        }