Example #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);
        }
Example #2
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;
        }