public List <CompanyModel> GetCompanies(UserModel userModel)
        {
            var companiesModel      = new List <CompanyModel>();
            var userCompanyBussines = new BUserCompany();
            var userEntity          = helperSession.mapping.CreateMapper().Map <UserModel, EUser>(userModel);
            var companiesEntity     = userCompanyBussines.SelectByUser(userEntity);

            userModel = helperSession.mapping.CreateMapper().Map <EUser, UserModel>(userEntity);
            foreach (var companyEntity in companiesEntity)
            {
                var companyModel = helperSession.mapping.CreateMapper().Map <ECompany, CompanyModel>(companyEntity);
                companiesModel.Add(companyModel);
            }
            return(companiesModel);
        }
        public void DeleteByUser()
        {
            bool             result                 = false;
            List <ECompany>  listECompanies         = new List <ECompany>();
            BUserCompany     bUserCompany           = new BUserCompany();
            EUserCompany     eUserCompany           = new EUserCompany();
            EUserCompany     insertedOneUserCompany = new EUserCompany();
            EUserCompany     insertedTwoUserCompany = new EUserCompany();
            BCorporation     bCorporation           = new BCorporation();
            ECorporation     eCorporation           = new ECorporation();
            BCompany         bCompany               = new BCompany();
            ECompany         eCompany               = new ECompany();
            BUser            bUser = new BUser();
            EUser            eUser = new EUser();
            TransactionScope ts    = new TransactionScope(TransactionScopeOption.RequiresNew);

            eCorporation.CodeCorporation    = Aleatory.GetString(2);
            eCorporation.Name               = Aleatory.GetString(15);
            eCorporation.State              = Aleatory.GetShort();
            eCorporation.Audit.UserRegister = Aleatory.GetString(8);
            bCorporation.Insert(eCorporation);

            eCompany.CodeCompany        = Aleatory.GetString(2);
            eCompany.CodeCorporation    = eCorporation.CodeCorporation;
            eCompany.Ruc                = Aleatory.GetString(11);
            eCompany.LongName           = Aleatory.GetString(15);
            eCompany.State              = Aleatory.GetShort();
            eCompany.Audit.UserRegister = Aleatory.GetString(8);
            bCompany.Insert(eCompany);

            eUser.CodeUser           = Aleatory.GetString(8);
            eUser.Name               = Aleatory.GetString(8);
            eUser.Password           = Aleatory.GetString(8);
            eUser.State              = Aleatory.GetShort();
            eUser.Audit.UserRegister = Aleatory.GetString(8);
            bUser.Insert(eUser);

            eUserCompany.CodeUser    = eUser.CodeUser;
            eUserCompany.CodeCompany = eCompany.CodeCompany;
            bUserCompany.Insert(eUserCompany);

            insertedOneUserCompany = bUserCompany.Select(eUserCompany);

            eCompany.CodeCompany        = Aleatory.GetString(2);
            eCompany.CodeCorporation    = eCorporation.CodeCorporation;
            eCompany.LongName           = Aleatory.GetString(15);
            eCompany.State              = Aleatory.GetShort();
            eCompany.Audit.UserRegister = Aleatory.GetString(8);
            bCompany.Insert(eCompany);

            eUserCompany.CodeUser    = eUser.CodeUser;
            eUserCompany.CodeCompany = eCompany.CodeCompany;
            bUserCompany.Insert(eUserCompany);

            insertedTwoUserCompany = bUserCompany.Select(eUserCompany);

            listECompanies = bUserCompany.SelectByUser(eUser);

            if (listECompanies.Count == 2 &&
                listECompanies.Exists(x => x.CodeCompany == insertedOneUserCompany.CodeCompany) &&
                listECompanies.Exists(x => x.CodeCompany == insertedTwoUserCompany.CodeCompany))
            {
                bUserCompany.DeleteByUser(eUser);
            }

            listECompanies = bUserCompany.SelectByUser(eUser);

            if (listECompanies.Count == 0)
            {
                result = true;
            }

            Assert.IsTrue(result);
        }