예제 #1
0
        private async Task CreateCompanyAppAsync(string connectionString, CompanyDto companyInputDto, string companyGUID, string objectGuid, string userId)
        {
            var obj = new CompanyAppObject()
            {
                ObjectName = "Стандарт",
                ObjectSlug = "standart",
                GUID       = objectGuid,
                IsActive   = true
            };

            var companyAppSlug = stringGenerator.GenerateSlug(companyInputDto.Name);
            var companyApp     = new CompanyApp()
            {
                CompanyName       = companyInputDto.Name,
                ConnStr           = connectionString,
                GUID              = companyGUID,
                Description       = companyInputDto.Description,
                CompanySlug       = companyAppSlug,
                ApplicationUserId = userId,
                IsActive          = false,
                IsVatRegistered   = companyInputDto.IsVatRegistered,
            };

            companyApp.CompanyAppObjects.Add(obj);

            await companyAppRepo.AddAsync(companyApp);

            await companyAppRepo.SaveChangesAsync();
        }
예제 #2
0
        public async Task CreateCompany_AlreadExists()
        {
            //Arrange
            UnityOfWorkContract    unityOfWork    = new ResolveMock().Resolve();
            CompanyServiceContract companyService = new CompanyService(unityOfWork);
            CompanyAppContract     _companyApp    = new CompanyApp(unityOfWork, companyService);

            Company company = new Company("68522679000112", "Company Name", null);

            //Act
            company = await _companyApp.Create(company);

            //Assert
            Assert.AreEqual(true, company.EventNotification.Warnings.Select(x => x.ToString()).Contains("Empresa já Cadastrada."));
        }
예제 #3
0
        public async Task CreateCompany_CNPJ_Wrong()
        {
            //Arrange
            UnityOfWorkContract    unityOfWork    = new ResolveMock().Resolve();
            CompanyServiceContract companyService = new CompanyService(unityOfWork);
            CompanyAppContract     _companyApp    = new CompanyApp(unityOfWork, companyService);

            Company company = new Company("10793548000191", "Company Name", State.Acre);

            //Act
            company = await _companyApp.Create(company);

            //Assert
            Assert.AreEqual(true, company.EventNotification.Warnings.Select(x => x.ToString()).Contains("CNPJ Inválido."));
        }
예제 #4
0
        public async Task CreateCompany_StateEmpty()
        {
            //Arrange
            UnityOfWorkContract    unityOfWork    = new ResolveMock().Resolve();
            CompanyServiceContract companyService = new CompanyService(unityOfWork);
            CompanyAppContract     _companyApp    = new CompanyApp(unityOfWork, companyService);

            Company company = new Company("10793548000190", "Company Name", null);

            //Act
            company = await _companyApp.Create(company);

            //Assert
            Assert.AreEqual(true, company.EventNotification.Warnings.Select(x => x.ToString()).Contains("Estado é obrigatório."));
        }
예제 #5
0
        public async Task UpdateCompany_NotFound()
        {
            //Arrange
            UnityOfWorkContract    unityOfWork    = new ResolveMock().Resolve();
            CompanyServiceContract companyService = new CompanyService(unityOfWork);
            CompanyAppContract     _companyApp    = new CompanyApp(unityOfWork, companyService);

            Company company = new Company("10793548000190", "Company Name alt", State.Acre);

            //Act
            company = await _companyApp.Update(company);

            //Assert
            Assert.AreEqual(true, company.EventNotification.Warnings.Select(x => x.ToString()).Contains("Empresa não encontrada."));
        }
예제 #6
0
        public async Task DeleteCompany_CNPJ_Required()
        {
            //Arrange
            UnityOfWorkContract    unityOfWork    = new ResolveMock().Resolve();
            CompanyServiceContract companyService = new CompanyService(unityOfWork);
            CompanyAppContract     _companyApp    = new CompanyApp(unityOfWork, companyService);

            Company company = new Company("", "", null);

            //Act
            company = await _companyApp.Delete(company);

            //Assert
            Assert.AreEqual(true, company.EventNotification.Warnings.Select(x => x.ToString()).Contains("CNPJ da Empresa é obrigatório."));
        }
예제 #7
0
        public async Task DeleteCompany()
        {
            //Arrange
            UnityOfWorkContract    unityOfWork    = new ResolveMock().Resolve();
            CompanyServiceContract companyService = new CompanyService(unityOfWork);
            CompanyAppContract     _companyApp    = new CompanyApp(unityOfWork, companyService);

            Company company = new Company("68522679000112", "", null);

            //Act
            company = await _companyApp.Delete(company);

            CompanyList itens = await _companyApp.Get();

            //Assert
            Assert.AreEqual(3, itens.Itens.Count);
        }
예제 #8
0
        public async Task CreateCompany()
        {
            //Arrange
            UnityOfWorkContract    unityOfWork    = new ResolveMock().Resolve();
            CompanyServiceContract companyService = new CompanyService(unityOfWork);
            CompanyAppContract     _companyApp    = new CompanyApp(unityOfWork, companyService);

            Company company = new Company("10793548000190", "Company Name", State.Acre);

            //Act
            company = await _companyApp.Create(company);

            CompanyList itens = await _companyApp.Get();

            //Assert
            Assert.AreEqual(true, company.IsValid());
            Assert.AreEqual(5, itens.Itens.Count);
        }
예제 #9
0
        public async Task UpdateCompany()
        {
            string newName  = "Company Name alt";
            State  newState = State.SantaCatarina;
            //Arrange
            UnityOfWorkContract    unityOfWork    = new ResolveMock().Resolve();
            CompanyServiceContract companyService = new CompanyService(unityOfWork);
            CompanyAppContract     _companyApp    = new CompanyApp(unityOfWork, companyService);

            Company company = new Company("68522679000112", newName, newState);

            //Act
            company = await _companyApp.Update(company);

            Company companyUpdated = await _companyApp.Get(company.CNPJ);

            //Assert
            Assert.AreEqual(true, companyUpdated.CompanyName == newName && companyUpdated.State == newState);
        }
예제 #10
0
        public Menu()
        {
            _conn = new RepositoryInjection().GetClass <IFactoryConnection>();

            InitializeComponent();
            //var catalog = new AggregateCatalog(new AssemblyCatalog(Assembly.GetExecutingAssembly()), new DirectoryCatalog("."));
            //var container = new CompositionContainer(catalog);
            //container.ComposeParts(this);

            //foreach (var plugin in Modules)
            //{
            //    //plugin.SetGrid(((FMain)Tag).GridSearch);
            //    foreach (var item in plugin.ItemsCollection())
            //    {
            //        this.Items().Add(item);
            //    }
            //}

            if (GlobalUser.User == null)
            {
                return;
            }

            MenuPaindelControle.Visibility = GlobalUser.User.IsAdministrator ? Visibility.Visible : Visibility.Collapsed;

            //ModuleEstacionamento.Visibility = Visibility.Collapsed;

            var companies = new CompanyApp(_conn).Search(c => GlobalUser.User.AccessAllCompanies || c.UsersCompanies.Any(d => d.UserId == GlobalUser.User.Id));

            foreach (var item in companies)
            {
                var itemMenu = new RibbonApplicationMenuItem()
                {
                    Header = string.Format("{0} - {1}", item.Id, item.CorporateName), Tag = item
                };
                itemMenu.Click += MenuItemCompanies_Click;
                ListCompanies.Items.Add(
                    itemMenu
                    );
            }
        }
예제 #11
0
        public FFilterCompany()
        {
            StateForm = StateForm.Editing;

            InitializeComponent();

            sMenuProcess1.Visibility = System.Windows.Visibility.Hidden;
            elementHost1.Visible     = false;

            gridFilterCompany.SMenuComponent.Visible   = false;
            gridFilterCompany.Label.Visible            = false;
            gridFilterCompany.SComponent.SelectionMode = DataGridViewSelectionMode.CellSelect;

            var ri = new RepositoryInjection();

            _conn = ri.GetClass <IFactoryConnection>();

            _filterCompanyApp = new FilterCompanyApp(_conn);
            _companyApp       = new CompanyApp(_conn);
            _dbTableApp       = new DbTableApp(_conn);

            InitializeStrutureColumns();
            UpdateDataSource();
        }
예제 #12
0
 public CompanyController(IFactoryConnection connection)
 {
     _connection = connection;
     _CompanyApp = new CompanyApp(connection);
 }
예제 #13
0
        public FLogin(SplashScreen splash)
        {
            _splashScreen = splash;
            var ri   = new RepositoryInjection();
            var conn = ri.GetClass <IFactoryConnection>();

            _userApp               = new UserApp(conn);
            _companyApp            = new CompanyApp(conn);
            _translateApp          = new TranslateApp(conn);
            _tableApp              = new TableApp(conn);
            _dbTableApp            = new DbTableApp(conn);
            _automaticNumberingApp = new AutomaticNumberingApp(conn);

            _userController = new UserController(conn);

            GlobalUser.Forms               = _tableApp.Search().ToList();
            GlobalUser.Translates          = _translateApp.Search().ToList();
            GlobalUser.Tables              = _dbTableApp.Search().ToList();
            GlobalUser.AutomaticNumberings = _automaticNumberingApp.Search().ToList();

            InitializeComponent();

            Unidade.ObjetoApp     = new InvokeMethod(typeof(CompanyController), TypeExecute.SearchAll, "ListCompany", typeof(Company));
            Unidade.DisplayMember = "PersonName";
            Unidade.ValueMember   = "Id";
            Unidade.Enabled       = false;
            Unidade.Refresh();
            Unidade.SComponent.DropDown += SComponentOnDropDown;
            Unidade.Caption              = "Unidade";

            EntrarButton.SComponent.BackColor = Color.DarkSlateGray;
            EntrarButton.SComponent.ForeColor = Color.White;
            EntrarButton.SComponent.Text      = @"Entrar";
            EntrarButton.SComponent.Click    += EntrarButton_Click;
            EntrarButton.Enabled = false;

            SenhaTextBox.SComponent.PasswordChar = '*';
            SenhaTextBox.Caption = "Senha";
            SenhaTextBox.SComponent.TextChanged += SenhaComponentOnTextChanged;

            UsuarioTextBox.SComponent.TextChanged += UsuarioComponentOnTextChanged;
            UsuarioTextBox.Caption = "Login";

            var cont = false;

            if (_companyApp.Search().Any())
            {
                if (!_userApp.Search().Any())
                {
                    MessageBox.Show(@"Necessário cadastrar um usuário",
                                    @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.OK);
                    var fuser = new FUser
                    {
                        StateForm       = StateForm.Inserting,
                        ClosedAfterSave = true
                    };
                    fuser.RefreshControls();
                    ((User)fuser.CurrentControl).IsAdministrator = true;
                    _splashScreen.Close();
                    fuser.ShowDialog();
                }
                return;
            }
            ;
            MessageBox.Show(@"Este é o seu primeiro acesso ao sistema, por favor, cadastre sua empresa.",
                            @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.OK);

            do
            {
                var fcompany = new FCompany()
                {
                    StateForm       = StateForm.Inserting,
                    ClosedAfterSave = true
                };
                fcompany.RefreshControls();
                _splashScreen.Close();
                fcompany.ShowDialog();
                if (!_companyApp.Search().Any())
                {
                    cont = MessageBox.Show(@"Necessário cadastrar uma empresa, deseja continuar ?",
                                           @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
                           DialogResult.Yes;
                }
            } while (cont);

            if (!_companyApp.Search().Any())
            {
                Close();
            }
            else
            {
                if (_userApp.Search().Any())
                {
                    return;
                }
                MessageBox.Show(@"Necessário cadastrar um usuário",
                                @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.OK);
                var fuser = new FUser
                {
                    ClosedAfterSave = true,
                    StateForm       = StateForm.Inserting,
                };
                ((User)fuser.CurrentControl).IsAdministrator = true;
                _splashScreen.Close();
                fuser.ShowDialog();
            }
        }