/// <summary>
 /// TaxService Constructor
 /// </summary>
 /// <param name="taxRepository"></param>
 /// <param name="taxServiceValidator"></param>
 /// <param name="logger"></param>
 public TaxService(ITaxRepository taxRepository, ITaxServiceValidator taxServiceValidator, IConsumerHelper consumerHelper, ILogger <TaxService> logger)
 {
     _taxRepository       = taxRepository;
     _logger              = logger;
     _taxServiceValidator = taxServiceValidator;
     _consumerHelper      = consumerHelper;
 }
        public void Initialize()
        {
            //Arrange
            var databaseFactory = new DatabaseFactory();

            _unitOfWork = new UnitOfWork(databaseFactory);

            _settingRepository                  = new SettingRepository(databaseFactory);
            _employeeInfoRepository             = new EmployeeInfoRepository(databaseFactory);
            _employeeDeductionRepository        = new EmployeeDeductionRepository(databaseFactory);
            _deductionRepository                = new DeductionRepository(databaseFactory);
            _employeePayrollRepository          = new EmployeePayrollRepository(databaseFactory);
            _employeePayrollDeductionRepository = new EmployeePayrollDeductionRepository(databaseFactory);
            _taxRepository = new TaxRepository(databaseFactory);
            _totalEmployeeHoursRepository = new TotalEmployeeHoursRepository(databaseFactory);

            _settingService            = new SettingService(_settingRepository);
            _employeeSalaryService     = new EmployeeSalaryService();
            _employeeInfoService       = new EmployeeInfoService(_employeeInfoRepository);
            _employeeDeductionService  = new EmployeeDeductionService(_employeeDeductionRepository);
            _deductionService          = new DeductionService(_deductionRepository);
            _totalEmployeeHoursService = new TotalEmployeeHoursService(_unitOfWork, _totalEmployeeHoursRepository, null, _settingService);

            _taxService = new TaxService(_taxRepository);

            _employeePayrollDeductionService = new EmployeePayrollDeductionService(_unitOfWork, _settingService, _employeeSalaryService, _employeeInfoService, _employeeDeductionService, _deductionService, _employeePayrollDeductionRepository, _taxService);
        }
Пример #3
0
 public TaxService(ITaxRepository taxRepository, IMapper mapper, IClientService clientService, IProductService productService)
 {
     this.taxRepository  = taxRepository;
     this.mapper         = mapper;
     this.productService = productService;
     this.clientService  = clientService;
 }
Пример #4
0
        public void Startup()
        {
            _orderRepository           = new TestOrderRepository();
            _catalogRepository         = new TestCatalogRepository();
            _addressValidation         = new TestAddressValidator();
            _shippingRepository        = new TestShippingRepository();
            _shippingService           = new SimpleShippingService(_shippingRepository);
            _taxRepository             = new TestTaxRepository();
            _taxService                = new RegionalSalesTaxService(_taxRepository);
            _orderService              = new OrderService(_orderRepository, _catalogRepository, _shippingRepository, _shippingService);
            _personalizationRepository = new TestPersonalizationRepository();
            _personalizationService    = new PersonalizationService(_personalizationRepository, _orderRepository, _orderService, _catalogRepository);
            _catalogService            = new CatalogService(_catalogRepository, _orderService);
            _paymentService            = new FakePaymentService();
            _incentiveRepository       = new TestIncentiveRepository();
            _incentiveService          = new IncentiveService(_incentiveRepository);

            //this service throws the sent mailers into a collection
            //and does not use SMTP
            _mailerService       = new TestMailerService();
            _inventoryRepository = new TestInventoryRepository();
            _inventoryService    = new InventoryService(_inventoryRepository, _catalogService);
            _mailerRepository    = new TestMailerRepository();
            _pipeline            = new DefaultPipeline(
                _addressValidation, _paymentService,
                _orderService, _mailerService,
                _inventoryService
                );
        }
Пример #5
0
 public TaxManager(ITaxRepository taxRepository, IMapper mapper)
 {
     _taxRepository = taxRepository ??
                      throw new ArgumentNullException(nameof(_taxRepository));;
     _mapper = mapper ??
               throw new ArgumentNullException(nameof(_mapper));;
 }
Пример #6
0
 public TaxController(
     ITaxRepository _Tax
     , IUserRepository _user
     , ITaxIncomePersonDetailRepository _taxpd
     , ITaxIncomePersonRepository _taxp
     , IStaffsRepository _staff
     , ISalaryTableDetailReportRepository _salaryReport
     , ICategoryRepository _cate
     , IThuNhapChiuThueRepository _thunhap
     , IGiamTruThueTNCNRepository _giamtru
     , ITaxRateRepository _taxrate
     , IStaffFamilyRepository _staff_f
     )
 {
     TaxRepository  = _Tax;
     userRepository = _user;
     taxIncomePersonDetailRepository = _taxpd;
     taxIncomePersonRepository       = _taxp;
     staffsRepository = _staff;
     salaryTableDetailReportRepository = _salaryReport;
     categoryRepository        = _cate;
     thuNhapChiuThueRepository = _thunhap;
     giamTruThueTNCNRepository = _giamtru;
     taxRateRepository         = _taxrate;
     staffFamilyRepository     = _staff_f;
 }
Пример #7
0
        public void Startup()
        {
            _orderRepository = new TestOrderRepository();
            _catalogRepository = new TestCatalogRepository();
            _addressValidation = new TestAddressValidator();
            _shippingRepository = new TestShippingRepository();
            _shippingService = new SimpleShippingService(_shippingRepository);
            _taxRepository = new TestTaxRepository();
            _taxService = new RegionalSalesTaxService(_taxRepository);
            _orderService = new OrderService(_orderRepository,_catalogRepository,_shippingRepository,_shippingService);
            _personalizationRepository = new TestPersonalizationRepository();
            _personalizationService = new PersonalizationService(_personalizationRepository,_orderRepository, _orderService,_catalogRepository);
            _catalogService = new CatalogService(_catalogRepository,_orderService);
            _paymentService = new FakePaymentService();
            _incentiveRepository = new TestIncentiveRepository();
            _incentiveService = new IncentiveService(_incentiveRepository);

            //this service throws the sent mailers into a collection
            //and does not use SMTP
            _mailerService = new TestMailerService();
            _inventoryRepository = new TestInventoryRepository();
            _inventoryService = new InventoryService(_inventoryRepository,_catalogService);
            _mailerRepository = new TestMailerRepository();
            _pipeline=new DefaultPipeline(
                _addressValidation,_paymentService,
                _orderService,_mailerService,
                _inventoryService
                );


        }
Пример #8
0
        public PrestaShopSynchronizeService(
            IConfiguration _configuration,
            ILogger <PrestaShopSynchronizeService> _logger,
            IUnitOfWorkProvider _unitOfWorkProvider,
            ISynchronizeStampRepository _synchronizeStampRepository,
            IPrestaShopClient _prestaShopClient,
            ISupplierRepository _supplierRepository,
            ICategoryRepository _categoryRepository,
            IProductRepository _productRepository,
            ITaxRepository _taxRepository,
            IPrestaShopSynchronizeCustomer _prestaShopSynchronizeCustomer,
            IPrestaShopSynchronizeOrder _prestaShopSynchronizeOrder)
        {
            configuration                 = _configuration;
            logger                        = _logger;
            unitOfWorkProvider            = _unitOfWorkProvider;
            prestaShopClient              = _prestaShopClient;
            synchronizeStampRepository    = _synchronizeStampRepository;
            supplierRepository            = _supplierRepository;
            categoryRepository            = _categoryRepository;
            productRepository             = _productRepository;
            taxRepository                 = _taxRepository;
            prestaShopSynchronizeCustomer = _prestaShopSynchronizeCustomer;
            prestaShopSynchronizeOrder    = _prestaShopSynchronizeOrder;

            bool b;

            SynchronizationDisabled     = bool.TryParse(configuration["PrestaShop:Synchronization:Disabled"], out b) ? b : false;
            CustomerSynchronizeDisabled = bool.TryParse(configuration["PrestaShop:Synchronization:Customers:Disabled"], out b) ? b : false;
        }
        public async Task GivenACountryCode_ReturnsTaxRate()
        {
            _taxRepository = new TaxRepository(_connectionStringConfig.Object);

            var taxRates = await _taxRepository.GetTaxRate(CountryCode);

            taxRates.Single().TaxRate.ShouldBe(15);
        }
Пример #10
0
 protected BaseService(IReportRepository reportRepository, ITaxRepository taxRepository, IOAuthService oAuthService, string entityName)
 {
     _reportRepository = reportRepository;
     _log           = LogManager.GetLogger(GetType());
     EntityName     = entityName;
     _taxRepository = taxRepository;
     _oAuthService  = oAuthService;
 }
Пример #11
0
 public CurrencyService(ICurrencyRepository currencyRepository, IPensionRepository pensionRepository, ITaxRepository taxRepository, ISalaryRepository salaryRepository, IBankAccountRepository bankAccountRepository)
 {
     this._currencyRepository    = currencyRepository;
     this._bankAccountRepository = bankAccountRepository;
     this._salaryRepository      = salaryRepository;
     this._pensionRepository     = pensionRepository;
     this._taxRepository         = taxRepository;
 }
Пример #12
0
 public CountryService(ICountryRepository countryRepository, IPensionRepository pensionRepository, ITaxRepository taxRepository, ISalaryRepository salaryRepository, IBankRepository bankRepository)
 {
     this._countryRepository = countryRepository;
     this._bankRepository    = bankRepository;
     this._salaryRepository  = salaryRepository;
     this._pensionRepository = pensionRepository;
     this._taxRepository     = taxRepository;
 }
Пример #13
0
        public void Setup()
        {
            _mockFeeRepository = Substitute.For <IFeeRepository>();
            _mockTaxRepository = Substitute.For <ITaxRepository>();
            _mockProvider      = Substitute.For <IRemittanceProvider>();

            _service = new TaxAndFeeService(_mockProvider, _mockTaxRepository, _mockFeeRepository);
        }
Пример #14
0
 public ShoppingCartService(IProductRepository productRepository, IShoppingCartSingleton shoppingCartSingleton, AutoNumberGenerator autoNumberGenerator, ICurrencyRepository currencyRepository, ITaxRepository taxRepository, IServiceChargeRepository serviceChargeRepository)
 {
     this.productRepository = productRepository;
     this.shoppingCartSingleton = shoppingCartSingleton;
     this.autoNumberGenerator = autoNumberGenerator;
     this.currencyRepository = currencyRepository;
     this.taxRepository = taxRepository;
     this.serviceChargeRepository = serviceChargeRepository;
 }
Пример #15
0
 public ExchangeService(
     IFactorRepository factorRepository,
     ITaxRepository taxRepository,
     ILogger <ExchangeService> logger)
 {
     _factorRepository = factorRepository;
     _taxRepository    = taxRepository;
     _logger           = logger;
 }
Пример #16
0
        public TaxService(ITaxRepository taxRepository)
        {
            this._taxRepository = taxRepository;

            if (this._taxRepository == null)
            {
                throw new ArgumentNullException("TaxService.ITaxRepository");
            }
        }
Пример #17
0
        public OrderManager(IOrderRepository orders, IProductRepository products, ITaxRepository taxes)
        {
            _orders   = orders;
            _products = products;
            _taxes    = taxes;

            Products = _products.RetrieveProducts();
            Taxes    = _taxes.RetrieveTaxes();
        }
Пример #18
0
        protected override void ExecuteInContext(IUnitOfWorkContext context, AddInvoiceItem command)
        {
            ITaxRepository taxRepo = NcqrsEnvironment.Get <ITaxRepository>();
            Tax            tax     = taxRepo.FindByCode(command.TaxCode, command.OwnerId);

            Invoice invoice = context.GetById <Invoice>(command.InvoiceId, command.KnownVersion);

            invoice.AddInvoiceItem(command.ItemId, command.Description, command.Quantity, command.Price, command.DiscountInPercent, tax, command.OwnerId, command.UserName);
            context.Accept();
        }
Пример #19
0
 public AccountCountrySettingsValidator(
     ITaxRepository arg0,
     IAccountCountrySettingsRepository arg1,
     IOrganizationCompanyRepository arg2
     ) : base()
 {
     field0 = arg0;
     field1 = arg1;
     field2 = arg2;
 }
Пример #20
0
 public TaxBusiness(IMapper mapper,
                    ITaxRepository taxRepository,
                    IRestaurantRepository restaurantRepository,
                    IMenuUnitRepository menuUnitRepository)
 {
     _mapper               = mapper;
     _taxRepository        = taxRepository;
     _restaurantRepository = restaurantRepository;
     _menuUnitRepository   = menuUnitRepository;
 }
Пример #21
0
 public TaxProvider(ILogger <TaxProvider> logger,
                    ITaxRepository taxRepository,
                    ITaxProviderValidator taxProviderValidator,
                    ITaxProviderMapper taxProviderMapper)
 {
     _taxRepository        = taxRepository;
     _taxProviderLogger    = logger;
     _taxProviderValidator = taxProviderValidator;
     _taxProviderMapper    = taxProviderMapper;
 }
        public void Initialize()
        {
            //Arrange
            var databaseFactory = new DatabaseFactory();

            _unitOfWork = new UnitOfWork(databaseFactory);

            _employeeDailyPayrollRepository = new EmployeeDailyPayrollRepository(databaseFactory);
            _employeePayrollRepository      = new EmployeePayrollRepository(databaseFactory);
            _settingRepository = new SettingRepository(databaseFactory);
            _employeePayrollDeductionRepository = new EmployeePayrollDeductionRepository(databaseFactory);
            _employeeInfoRepository             = new EmployeeInfoRepository(databaseFactory);
            _totalEmployeeHoursRepository       = new TotalEmployeeHoursRepository(databaseFactory);
            _deductionRepository         = new DeductionRepository(databaseFactory);
            _employeeDeductionRepository = new EmployeeDeductionRepository(databaseFactory);
            _taxRepository                 = new TaxRepository(databaseFactory);
            _employeeRepository            = new EmployeeRepository(databaseFactory, null);
            _employeePayrollItemRepository = new EmployeePayrollItemRepository(databaseFactory);
            _employeeAdjustmentRepository  = new EmployeeAdjustmentRepository(databaseFactory);

            _settingService = new SettingService(_settingRepository);
            _employeeDailyPayrollService = new EmployeeDailyPayrollService(_unitOfWork,
                                                                           null, null, null, null, _employeeDailyPayrollRepository, null, null);
            _employeeInfoService      = new EmployeeInfoService(_employeeInfoRepository);
            _deductionService         = new DeductionService(_deductionRepository);
            _employeeDeductionService = new EmployeeDeductionService(_employeeDeductionRepository);
            _taxService = new TaxService(_taxRepository);
            _employeePayrollDeductionService = new EmployeePayrollDeductionService(_unitOfWork, _settingService, null, _employeeInfoService, _employeeDeductionService, _deductionService, _employeePayrollDeductionRepository, _taxService);
            _employeeService                 = new EmployeeService(_employeeRepository);
            _totalEmployeeHoursService       = new TotalEmployeeHoursService(_unitOfWork, _totalEmployeeHoursRepository, null, _settingService);
            _employeePayrollItemService      = new EmployeePayrollItemService(_unitOfWork, _employeePayrollItemRepository, null, null, null, null, null, null, null, null, null, null, null);
            _employeeAdjusmentService        = new EmployeeAdjustmentService(_employeeAdjustmentRepository, _employeeRepository);
            _employeePayrollAllowanceService = new EmployeePayrollAllowanceService(_settingService, _totalEmployeeHoursService);
            _employeePayrollService          = new EmployeePayrollService(_unitOfWork, _employeePayrollRepository, _settingService, _employeePayrollDeductionService, _employeeInfoService, _totalEmployeeHoursService, _employeeService, _totalEmployeeHoursService, _employeePayrollItemService, _employeeAdjusmentService, _employeePayrollAllowanceService);

            //Update settings
            var settingsPayrollStartDate = _settingRepository.GetSettingByKey("PAYROLL_WEEK_START");

            _settingRepository.Update(settingsPayrollStartDate);
            settingsPayrollStartDate.Value = "3";

            var settingsPayrollEndDate = _settingRepository.GetSettingByKey("PAYROLL_WEEK_END");

            _settingRepository.Update(settingsPayrollEndDate);
            settingsPayrollEndDate.Value = "2";

            var settingsPayrollReleaseDate = _settingRepository.GetSettingByKey("PAYROLL_WEEK_RELEASE");

            _settingRepository.Update(settingsPayrollReleaseDate);
            settingsPayrollReleaseDate.Value = "3";

            _unitOfWork.Commit();
        }
Пример #23
0
        public void Setup()
        {
            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appsettings.json", optional: true)
                                .AddUserSecrets("ccd05d39-4c3d-42e9-ac50-87bb97e1d73b")
                                .Build();

            _taxRepository = new TaxRepository(
                new DataStoreConfiguration(
                    configuration["CosmosEndpoint"],
                    configuration["CosmosPrimaryKey"]));
        }
Пример #24
0
        public ArticleViewModel(IArticleRepository articleRepository, ITaxRepository taxRepository,
                                IMeasureRepository measureRepository, IArticleTypeRepository articleTypeRepository,
                                IArticlePriceTypeRepository articlePriceTypeRepository)
        {
            _articleRepository          = articleRepository;
            _taxRepository              = taxRepository;
            _measureRepository          = measureRepository;
            _articleTypeRepository      = articleTypeRepository;
            _articlePriceTypeRepository = articlePriceTypeRepository;

            Header = $"{_measureRepository.GetEntities().Count()}";
        }
Пример #25
0
        /// <summary>
        /// Queries a list of TaxD states from a TaxData repository & returns a list
        /// </summary>
        /// <param name="repository">The TaxData repo</param>
        /// <returns>A list of unique tax states to choose from</returns>
        public List <string> DisplayAvailableTaxStates(ITaxRepository repository)
        {
            List <string> states = (from t in repository.Data
                                    where !string.IsNullOrEmpty(t.State)
                                    select t.State).Distinct().ToList();
            int count = 1;

            foreach (string s in states)
            {
                Console.WriteLine("\t" + $"{count++}. {s}");
            }

            return(states);
        }
Пример #26
0
 public FinPosService(ICompanyRepository companyRepository, IBranchRepository branchRepository, IUserRepository userRepository, IProductRepository productRepository, IPurchaseRepository purchaseRepository, ICategoryRepository categoryRepository, ILabelSettingRepository labelSettingRepository, ISupplierRepository supplierRepository, IOpeningStockRepository openingStockRepository, IStockAdjustmentRepository stockAdjustmentRepository, ISystemConfigurationRepository systemConfigurationRepository, ITaxRepository taxRepository)
 {
     _companyRepository             = companyRepository;
     _branchRepository              = branchRepository;
     _userRepository                = userRepository;
     _productRepository             = productRepository;
     _categoryRepository            = categoryRepository;
     _purchaseRepository            = purchaseRepository;
     _labelSettingRepository        = labelSettingRepository;
     _supplierRepository            = supplierRepository;
     _openingStockRepository        = openingStockRepository;
     _stockAdjustmentRepository     = stockAdjustmentRepository;
     _systemConfigurationRepository = systemConfigurationRepository;
     _taxRepository = taxRepository;
 }
        protected virtual IQueryable <StoreTaxProviderEntity> GetQuery(ITaxRepository repository, TaxProviderSearchCriteria criteria, IEnumerable <SortInfo> sortInfos)
        {
            var query = repository.StoreTaxProviders;

            if (!string.IsNullOrEmpty(criteria.Keyword))
            {
                query = query.Where(x => x.Code.Contains(criteria.Keyword) || x.Id.Contains(criteria.Keyword));
            }
            if (!criteria.StoreId.IsNullOrEmpty())
            {
                query = query.Where(x => x.StoreId == criteria.StoreId);
            }
            query = query.OrderBySortInfos(sortInfos);
            return(query);
        }
Пример #28
0
 public ReportsController(
     IDocumentRepository documentRepository,
     ITaxRepository taxRepository,
     IDetailRepository detailRepository,
     IUserRepository userRepository,
     IServiceRepository serviceRepository,
     IReportService reportService)
 {
     this.documentRepository = documentRepository;
     this.taxRepository      = taxRepository;
     this.detailRepository   = detailRepository;
     this.userRepository     = userRepository;
     this.serviceRepository  = serviceRepository;
     this.reportService      = reportService;
 }
Пример #29
0
        // private IReportService reportService;

        public OrdersController(
            IDocumentRepository documentRepository,
            ITaxRepository taxRepository,
            IDetailRepository detailRepository,
            IConfigurationRepository configurationRepository,
            IUserRepository userRepository,
            IServiceRepository serviceRepository,
            IReportService reportService)
        {
            this.documentRepository      = documentRepository;
            this.taxRepository           = taxRepository;
            this.detailRepository        = detailRepository;
            this.configurationRepository = configurationRepository;
            this.userRepository          = userRepository;
            this.serviceRepository       = serviceRepository;
            // this.reportService = reportService;
        }
        protected virtual IQueryable <StoreTaxProviderEntity> BuildQuery(ITaxRepository repository, TaxProviderSearchCriteria criteria)
        {
            var query = repository.StoreTaxProviders;

            if (!string.IsNullOrEmpty(criteria.Keyword))
            {
                query = query.Where(x => x.Code.Contains(criteria.Keyword) || x.Id.Contains(criteria.Keyword));
            }
            if (!criteria.StoreId.IsNullOrEmpty())
            {
                query = query.Where(x => x.StoreId == criteria.StoreId);
            }
            if (!criteria.StoreIds.IsNullOrEmpty())
            {
                query = query.Where(x => criteria.StoreIds.Contains(x.StoreId));
            }
            return(query);
        }
Пример #31
0
 public OptionBusiness(IMapper mapper,
                       IAdminGroupRepository adminGroupRepository,
                       IRestaurantRepository restaurantRepository,
                       IRestaurantBranchRepository restaurantBranchRepository,
                       IMenuCategoryRepository menuCategoryRepository,
                       IMenuUnitRepository menuUnitRepository,
                       IMenuSizeRepository menuSizeRepository,
                       IStateRepository stateRepository,
                       IStateCityRepository stateCityRepository,
                       ICustomerRepository customerRepository,
                       IOrderChannelRepository orderChannelRepository,
                       IRestaurantTableRepository restaurantTableRepository,
                       IAdminAccountRepository adminAccountRepository,
                       IOrderProcessRepository orderProcessRepository,
                       IIngredientRepository ingredientRepository,
                       IMenuDefinitionRepository menuDefinitionRepository,
                       IMenuRepository menuRepository,
                       ITaxRepository taxRepository)
 {
     _mapper = mapper;
     _adminGroupRepository       = adminGroupRepository;
     _restaurantRepository       = restaurantRepository;
     _restaurantBranchRepository = restaurantBranchRepository;
     _menuCategoryRepository     = menuCategoryRepository;
     _menuUnitRepository         = menuUnitRepository;
     _menuSizeRepository         = menuSizeRepository;
     _stateRepository            = stateRepository;
     _stateCityRepository        = stateCityRepository;
     _customerRepository         = customerRepository;
     _orderChannelRepository     = orderChannelRepository;
     _restaurantTableRepository  = restaurantTableRepository;
     _adminAccountRepository     = adminAccountRepository;
     _orderProcessRepository     = orderProcessRepository;
     _ingredientRepository       = ingredientRepository;
     _menuDefinitionRepository   = menuDefinitionRepository;
     _menuRepository             = menuRepository;
     _taxRepository = taxRepository;
 }
Пример #32
0
 public TaxManager(ITaxRepository taxRepository)
 {
     _taxRepository = taxRepository;
 }
 public RegionalSalesTaxService(ITaxRepository taxRepository)
 {
     _taxRepository = taxRepository;
 }
		public CalculateTaxActivity(ICatalogRepository catalogRepository, ITaxRepository taxRepository, ICacheRepository cacheRepository)
		{
			_catalogRepository = catalogRepository;
			_taxRepository = taxRepository;
			_cacheRepository = cacheRepository;
		}
Пример #35
0
 public List<StateTax> GetTaxInfo()
 {
     _taxRepo = TaxRepositoryFactory.CreateTaxRepository();
     return _taxRepo.GetStateTaxInformation();
 }
Пример #36
0
 public TaxService(ITaxRepository repository)
 {
     _repository = repository;
 }
Пример #37
0
 public TaxService(ITaxRepository taxRepository)
 {
     this.repository = taxRepository;
 }
Пример #38
0
 public TaxHelper(TaxYear taxYear, ITaxRepository taxRepo)
 {
     this._taxYear = taxYear;
     this._taxRepo = taxRepo;
 }
Пример #39
0
        public void Execute()
        {
            ConsoleIO.Header("\t~Edit Order~");
            DateTime orderDate = ConsoleIO.DateLookupPrompt();

            FlooringManager    flooringManager   = FlooringManagerFactory.Create(orderDate);
            IOrderRepository   orderRepo         = flooringManager.orderRepository;
            IProductRepository productRepository = flooringManager.productRepository;
            ITaxRepository     taxRepository     = flooringManager.taxRepository;

            ConsoleIO.Header("\t~Edit Order~");
            Dictionary <int, Order> orderDictionary = flooringManager.GetAllOrders(orderDate);

            //Order singleOrder = orderDictionary.TakeWhile(o=>o.Value.OrderDate==orderDate)

            if (orderRepo.FileExists())
            {
                if (orderRepo.LastOrder() == true)
                {
                    ConsoleIO.DisplayAllOrders(orderDictionary, false, true, orderDate);
                    Console.WriteLine();
                    string input = ConsoleIO.YOrNMessage("edit");
                    if (input == "Y")
                    {
                        DisplaySingleResponse singleResponse = flooringManager.GetOnlyOrder(orderDate);

                        ConsoleIO.EditOrder(singleResponse.Order, flooringManager.GetAllTaxes(), flooringManager.GetAllProducts());
                        ConsoleIO.Header("\t~Edit Order");
                        ConsoleIO.DisplaySingleOrder(singleResponse.Order, true);

                        do
                        {
                            singleResponse.Success = false;

                            string saveAnswer = ConsoleIO.SavePrompt().ToUpper();

                            if (saveAnswer == "Y")
                            {
                                //save and exit
                                //orderRepo.SaveOrder(response.Order);
                                orderRepo.CloseRepo(singleResponse.Order);
                                ConsoleIO.SaveCompleted();
                                singleResponse.Success = true;
                            }
                            else
                            {
                                string editAnswer = ConsoleIO.EditPrompt();
                                if (editAnswer == "Y")
                                {
                                    ConsoleIO.AllowEdit();
                                    ConsoleIO.KeyToContinue();
                                    Console.ReadKey();
                                    ConsoleIO.EditOrder(singleResponse.Order, flooringManager.GetAllTaxes(), flooringManager.GetAllProducts());
                                    ConsoleIO.Header("\t~Edit Order~");
                                    ConsoleIO.DisplaySingleOrder(singleResponse.Order, true);
                                    //edit answer
                                }
                                else if (editAnswer == "N")
                                {
                                    ConsoleIO.ReturnMenu("saving");
                                    singleResponse.Success = true;
                                    //dont save and go back to main menu
                                }
                                else
                                {
                                    //go back to save prompt
                                    ConsoleIO.Header("\t~Edit Order~");
                                    ConsoleIO.DisplaySingleOrder(singleResponse.Order, true);
                                    continue;
                                }
                            }
                        } while (singleResponse.Success != true);
                        //orderRepo.DeleteOrderFile();
                        //Console.WriteLine();
                        //ConsoleIO.OrderRemoved(0, true);
                        //ConsoleIO.KeyToContinue();
                        //Console.ReadKey();
                    }
                    //else
                    //{
                    //    //string editAnswer = ConsoleIO.EditPrompt();
                    //    //if (editAnswer == "Y")
                    //    //{
                    //    //    ConsoleIO.AllowEdit();
                    //    //    ConsoleIO.KeyToContinue();
                    //    //    Console.ReadKey();
                    //    //    ConsoleIO.EditOrder(response.Order, flooringManager.GetAllTaxes(), flooringManager.GetAllProducts());
                    //    //    ConsoleIO.Header("\t~Edit Order~");
                    //    //    ConsoleIO.DisplaySingleOrder(response.Order, true);
                    //    //    //edit answer
                    //    //}
                    //    //else if (editAnswer == "N")
                    //    //{
                    //    //    ConsoleIO.ReturnMenu("saving");
                    //    //    response.Success = true;
                    //    //    //dont save and go back to main menu
                    //    //}
                    //    //else
                    //    //{
                    //    //    //go back to save prompt
                    //    //    ConsoleIO.Header("\t~Edit Order~");
                    //    //    ConsoleIO.DisplaySingleOrder(response.Order, true);
                    //    //    continue;
                    //    //}
                    //}
                }
                else
                {
                    ConsoleIO.Header("\t~Edit Order~");
                    int orderNumber = ConsoleIO.GetIntFromUser(ConsoleIO.OrderLookup());

                    DisplaySingleResponse response = flooringManager.LookupOrder(orderNumber, orderDate);

                    if (response.Success)
                    {
                        ConsoleIO.Header("\t~Edit Order~");
                        ConsoleIO.DisplaySingleOrder(response.Order, true);
                        Console.WriteLine();
                        string input = ConsoleIO.YOrNMessage("edit");
                        if (input == "Y")
                        {
                            ConsoleIO.EditOrder(response.Order, flooringManager.GetAllTaxes(), flooringManager.GetAllProducts());
                            ConsoleIO.Header("\t~Edit Order");
                            ConsoleIO.DisplaySingleOrder(response.Order, true);
                            do
                            {
                                response.Success = false;

                                string saveAnswer = ConsoleIO.SavePrompt().ToUpper();

                                if (saveAnswer == "Y")
                                {
                                    //save and exit
                                    //orderRepo.SaveOrder(response.Order);
                                    orderRepo.CloseRepo(response.Order);
                                    ConsoleIO.SaveCompleted();
                                    response.Success = true;
                                }
                                else
                                {
                                    string editAnswer = ConsoleIO.EditPrompt();
                                    if (editAnswer == "Y")
                                    {
                                        ConsoleIO.AllowEdit();
                                        ConsoleIO.KeyToContinue();
                                        Console.ReadKey();
                                        ConsoleIO.EditOrder(response.Order, flooringManager.GetAllTaxes(), flooringManager.GetAllProducts());
                                        ConsoleIO.Header("\t~Edit Order~");
                                        ConsoleIO.DisplaySingleOrder(response.Order, true);
                                        //edit answer
                                    }
                                    else if (editAnswer == "N")
                                    {
                                        ConsoleIO.ReturnMenu("saving");
                                        response.Success = true;
                                        //dont save and go back to main menu
                                    }
                                    else
                                    {
                                        //go back to save prompt
                                        ConsoleIO.Header("\t~Edit Order~");
                                        ConsoleIO.DisplaySingleOrder(response.Order, true);
                                        continue;
                                    }
                                }
                            } while (response.Success != true);
                        }
                    }
                }
            }
            else
            {
                ConsoleIO.InvalidOrder();
                ConsoleIO.KeyToContinue();
                Console.ReadKey();
            }

            //else
            //{
            //    ConsoleIO.KeyToContinue();
            //    Console.ReadKey();
            //}
        }
Пример #40
0
		public override string Import(string catalogId, string propertySetId, ImportItem[] systemValues, ImportItem[] customValues, IRepository repository)
		{
			var _error = string.Empty;
			_repository = (ITaxRepository)repository;

			var action = GetAction(systemValues.First(x => x.Name == "Action").Value);

			switch (action)
			{
				case ImportAction.Insert:
					var itemI = systemValues.FirstOrDefault(y => y.Name == "TaxId");
					if (itemI != null)
					{
						var originalItem = _repository.Taxes.Where(x => x.TaxId == itemI.Value);
						if (originalItem.Count() == 0)
						{
							var name = systemValues.FirstOrDefault(y => y.Name == "TaxName");
							var type = systemValues.FirstOrDefault(y => y.Name == "TaxType");
							var addItem = new Tax { TaxId = itemI.Value, Name = name.Value, TaxType = Int32.Parse(type.Value) };
							_repository.Add(addItem);
							_repository.UnitOfWork.Commit();
						}
					}
					
					var tax = _repository.Taxes.Where(x => x.TaxId == itemI.Value);
					if (tax.Count() > 0)
					{
						var t = tax.First();
						var value = InitializeItem(null, systemValues);
						t.TaxValues.Add(value);
					}
					break;
				case ImportAction.InsertAndReplace:
					var itemR = systemValues.FirstOrDefault(y => y.Name == "TaxId");
					if (itemR != null)
					{
						var originalItem = _repository.Taxes.Where(x => x.TaxId == itemR.Value).SingleOrDefault();
						if (originalItem != null)
							_repository.Remove(originalItem);
					}

					var replaceItem = InitializeItem(null, systemValues);
					_repository.Add(replaceItem);
					break;
				case ImportAction.Update:
					//var itemU = systemValues.FirstOrDefault(y => y.Name == "PriceId");
					//if (itemU != null)
					//{
					//	var origItem = _repository.Taxes.Where(x => x.TaxId == itemU.Value).SingleOrDefault();
					//	if (origItem != null && origItem is TaxValue)
					//	{
					//		InitializeItem((TaxValue)origItem, systemValues);
					//		_repository.Update(origItem);
					//	}
					//}
					break;
				case ImportAction.Delete:
					var itemD = systemValues.FirstOrDefault(y => y.Name == "TaxId");
					if (itemD != null)
					{
						var deleteItem = _repository.Taxes.Where(x => x.TaxId == itemD.Value).SingleOrDefault();
						if (deleteItem != null)
							_repository.Remove(deleteItem);
					}
					break;
			}
			return _error;
		}