Ejemplo n.º 1
0
        public void AddToPositionExcel(string companyName, string departmentName, string name, string reportingPosName)
        {
            var company        = _companyUnitOfWork.CompanyRepository.GetAll().FirstOrDefault(e => e.Name == companyName);
            var department     = _departmentUnitOfWork.DepartmentRepository.GetAll().FirstOrDefault(e => e.Name == departmentName);
            var position       = _positionUnitOfWork.PositionRepository.GetAll().FirstOrDefault(e => e.Name == name);
            var reportPosition = _positionUnitOfWork.PositionRepository.GetAll().FirstOrDefault(e => e.Name == reportingPosName);

            if (position == null)
            {
                if (company != null)
                {
                    if (department != null)
                    {
                        if (reportPosition == null)
                        {
                            AddPosition(name, company.Id, department.Id, Guid.Empty);
                        }
                        else
                        {
                            AddPosition(name, company.Id, department.Id, reportPosition.Id);
                        }
                    }
                    else
                    {
                        _departmentManagementService = new DepartmentManagementService();
                        _departmentManagementService.AddDepartment(departmentName, company.Id, Guid.Empty);
                        AddPosition(name,
                                    _companyUnitOfWork.CompanyRepository.GetAll().FirstOrDefault(e => e.Name == companyName).Id,
                                    _departmentUnitOfWork.DepartmentRepository.GetAll()
                                    .FirstOrDefault(e => e.Name == departmentName)
                                    .Id,
                                    Guid.Empty
                                    );
                    }
                }
                else
                {
                    _companyManagementService = new CompanyManagementService();
                    _companyManagementService.AddCompany(companyName, Guid.Empty, string.Empty, string.Empty,
                                                         string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, DateTime.Now);
                    AddPosition(name,
                                _companyUnitOfWork.CompanyRepository.GetAll().FirstOrDefault(e => e.Name == companyName).Id,
                                _departmentUnitOfWork.DepartmentRepository.GetAll().FirstOrDefault(e => e.Name == departmentName).Id,
                                Guid.Empty
                                );
                }
            }
        }
Ejemplo n.º 2
0
        public void AddToBranchExcel(string companyName, string name, string description)
        {
            var company = _companyUnitOfWork.CompanyRepository.GetAll().FirstOrDefault(e => e.Name == companyName);
            var branch  = _branchUnitOfWork.BranchRepository.GetAll().FirstOrDefault(e => e.Name == name);

            if (branch == null)
            {
                if (company != null)
                {
                    AddBranch(name, company.Id, description);
                }
                else
                {
                    _companyManagementService = new CompanyManagementService();
                    _companyManagementService.AddCompany(companyName, Guid.Empty, string.Empty, string.Empty,
                                                         string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, DateTime.Now);
                    AddBranch(name,
                              _companyUnitOfWork.CompanyRepository.GetAll().FirstOrDefault(e => e.Name == companyName).Id,
                              description);
                }
            }
        }