public async Task <CustomerDto> GetAsync(int id)
        {
            var customerResult = await _customerService.GetCustomersAsync();

            var customer = customerResult.FirstOrDefault(x => x.Id == id);

            return(CustomerTranslator.Translate(customer));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>
        public CustomerDto Put([ModelBinder] Customer customer)
        {
            customer = _customerService.UpdateCustomer(customer);

            return(CustomerTranslator.Translate(customer));
        }
        public CustomerDto Post([ModelBinder] Customer customer)
        {
            _customerService.SaveCustomer(customer);

            return(CustomerTranslator.Translate(customer));
        }
        ///// <summary>
        ///// Get Customer By Id.
        ///// </summary>
        ///// <param name="id">Customer Id, Type Int</param>
        ///// <returns>Customer</returns>
        public CustomerDto Get(int id)
        {
            var customer = _customerService.GetCustomers().FirstOrDefault(x => x.Id == id);

            return(CustomerTranslator.Translate(customer));
        }
        public async Task <CustomerDto> PutAsync(Customer customer)
        {
            customer = await _customerService.UpdateCustomerAsync(customer);

            return(CustomerTranslator.Translate(customer));
        }
        public async Task <CustomerDto> PostAsync([ModelBinder] Customer customer)
        {
            await _customerService.SaveCustomerAsync(customer);

            return(CustomerTranslator.Translate(customer));
        }
        private void RunSynchronizationInBackground()
        {
            try {
                var serverAddress =
                    _configurationManager.GetConfig("Common")
                                         .GetSection("Server")
                                         .GetSetting("Address")
                                         .Value;
                var username =
                    _configurationManager.GetConfig("Common")
                                         .GetSection("Server")
                                         .GetSetting("Username")
                                         .Value;
                var password =
                    _configurationManager.GetConfig("Common")
                                         .GetSection("Server")
                                         .GetSetting("Password")
                                         .Value;
                var bathSize =
                    _configurationManager.GetConfig("Common")
                                         .GetSection("Synchronization")
                                         .GetSetting("BathSize")
                                         .As<int>();

                var databaseName =
                    _configurationManager.GetConfig("Common")
                                         .GetSection("Database")
                                         .GetSetting("FileName")
                                         .Value;
                var schemaScript =
                    _configurationManager.GetConfig("Common")
                                         .GetSection("Database")
                                         .GetSetting("SchemaScript")
                                         .Value;

                using (IWebServer webServer = new WebServer(serverAddress, username, password)) {
                    Notify(new TextNotification("Start synchronization"));
                    _view.ShowProgressBar();

                    AppCache.Clear();
                    Notify(new TextNotification("Routes synchronization"));
                    var routesRepository = _repositoryFactory.CreateRepository<Route>();
                    var routePointsRepository = _repositoryFactory.CreateRepository<RoutePoint>();
                    var routesSyncCmd =
                        new RoutesSynchronization(webServer, routesRepository, routePointsRepository,
                                                  _unitOfWorkFactory).RepeatOnError(3, 5000);
                    routesSyncCmd.Execute();

                    Notify(new TextNotification("Orders synchronization"));
                    var ordersRepository = _repositoryFactory.CreateRepository<Order>();
                    var ordersSyncCmd =
                        new OrdersSynchronization(webServer, ordersRepository,
                                                  _unitOfWorkFactory).RepeatOnError(3, 5000);
                    ordersSyncCmd.Execute();

                    if (_viewModel.SynchronizeFully) {
                        Notify(new TextNotification("Clear Database"));
                        _storageManager.DeleteCurrentStorage();

                        // Initialization
                        string databaseScriptFullPath = Environment.AppPath + schemaScript;
                        string databaseFileFullPath = Environment.AppPath + databaseName;
                        _storageManager.CreateOrOpenStorage(databaseFileFullPath,
                                                            databaseScriptFullPath);

                        Notify(new TextNotification("Greetings"));
                        var greetings = new Greetings(webServer);
                        greetings.Execute();
                    }

                    DateTime synchronizationDate = webServer.Connect().ServerTime();

                    // Customers synchronization
                    Notify(new TextNotification("Customers synchronization"));
                    var customerDtoRepository = new WebRepository<CustomerDto>(webServer);
                    var customerRepository = _repositoryFactory.CreateRepository<Customer>();
                    DtoTranslator<Customer, CustomerDto> customerTranslator =
                        new CustomerTranslator(_repositoryFactory);

                    Command<bool> customerSyncCmd = _viewModel.SynchronizeFully
                                                  ? new SynchronizationCommand
                                                        <CustomerDto,
                                                        Customer>(
                                                        customerDtoRepository,
                                                        customerRepository,
                                                        customerTranslator,
                                                        _unitOfWorkFactory,
                                                        bathSize)
                                                  : new SynchronizationCommand
                                                        <CustomerDto,
                                                        Customer>(
                                                        customerDtoRepository,
                                                        customerRepository,
                                                        customerTranslator,
                                                        _unitOfWorkFactory,
                                                        bathSize,
                                                        _viewModel
                                                            .LastSynchronizationDate);

                    customerSyncCmd = customerSyncCmd.RepeatOnError(3, 5000);
                    customerSyncCmd.Execute();
                    Notify(new ProgressNotification(7));

                    // Shipping addresses synchronization
                    Notify(new TextNotification("Shipping addresses synchronization"));
                    var shippingAddressDtoRepository =
                        new WebRepository<ShippingAddressDto>(webServer);
                    var shippingAddressSqLiteRepository =
                        _repositoryFactory.CreateRepository<ShippingAddress>();
                    DtoTranslator<ShippingAddress, ShippingAddressDto> shippingAddressdTranslator =
                        new ShippingAddressdTranslator();

                    Command<bool> shippingAddressSyncCmd =
                        _viewModel.SynchronizeFully
                            ? new SynchronizationCommand
                                  <ShippingAddressDto,
                                  ShippingAddress>(
                                  shippingAddressDtoRepository,
                                  shippingAddressSqLiteRepository,
                                  shippingAddressdTranslator,
                                  _unitOfWorkFactory,
                                  bathSize)
                            : new SynchronizationCommand
                                  <ShippingAddressDto,
                                  ShippingAddress>(
                                  shippingAddressDtoRepository,
                                  shippingAddressSqLiteRepository,
                                  shippingAddressdTranslator,
                                  _unitOfWorkFactory,
                                  bathSize,
                                  _viewModel
                                      .LastSynchronizationDate);
                    shippingAddressSyncCmd = shippingAddressSyncCmd.RepeatOnError(3, 5000);
                    shippingAddressSyncCmd.Execute();
                    Notify(new ProgressNotification(15));

                    // Categories synchronization
                    Notify(new TextNotification("Categories synchronization"));
                    var categoriesDtoRepository = new WebRepository<CategoryDto>(webServer);
                    var categorySqLiteRepository =
                        _repositoryFactory.CreateRepository<Category>();
                    DtoTranslator<Category, CategoryDto> categoriesTranslator =
                        new CategoryTranslator();
                    Command<bool> categoriesSyncCmd = _viewModel.SynchronizeFully
                                                    ? new CategotiesSynchronization
                                                          (
                                                          categoriesDtoRepository,
                                                          categorySqLiteRepository,
                                                          categoriesTranslator,
                                                          _unitOfWorkFactory,
                                                          bathSize)
                                                    : new CategotiesSynchronization
                                                          (
                                                          categoriesDtoRepository,
                                                          categorySqLiteRepository,
                                                          categoriesTranslator,
                                                          _unitOfWorkFactory,
                                                          bathSize,
                                                          _viewModel
                                                              .LastSynchronizationDate);

                    categoriesSyncCmd = categoriesSyncCmd.RepeatOnError(3, 5000);
                    categoriesSyncCmd.Execute();
                    Notify(new ProgressNotification(30));

                    // Statuses synchronization
                    Notify(new TextNotification("Statuses synchronization"));
                    var statusDtoRepository = new WebRepository<StatusDto>(webServer);
                    var statusSqLiteRepository =
                        _repositoryFactory.CreateRepository<Status>();
                    DtoTranslator<Status, StatusDto> statusTranslator = new StatusTranslator();

                    Command<bool> statusSyncCommand = _viewModel.SynchronizeFully
                                                    ? new SynchronizationCommand
                                                          <StatusDto, Status>(
                                                          statusDtoRepository,
                                                          statusSqLiteRepository,
                                                          statusTranslator,
                                                          _unitOfWorkFactory,
                                                          bathSize)
                                                    : new SynchronizationCommand
                                                          <StatusDto, Status>(
                                                          statusDtoRepository,
                                                          statusSqLiteRepository,
                                                          statusTranslator,
                                                          _unitOfWorkFactory,
                                                          bathSize,
                                                          _viewModel
                                                              .LastSynchronizationDate);

                    statusSyncCommand = statusSyncCommand.RepeatOnError(3, 5000);
                    statusSyncCommand.Execute();
                    Notify(new ProgressNotification(37));

                    // Warehouses synchronization
                    Notify(new TextNotification("Warehouses synchronization"));
                    var warehouseDtoRepository = new WebRepository<WarehouseDto>(webServer);
                    var warehouseSqLiteRepository =
                        _repositoryFactory.CreateRepository<Warehouse>();
                    DtoTranslator<Warehouse, WarehouseDto> warehouseTranslator =
                        new WarehouseTranslator();

                    Command<bool> warehouseSyncCommand =
                        _viewModel.SynchronizeFully
                            ? new SynchronizationCommand
                                  <WarehouseDto, Warehouse>(
                                  warehouseDtoRepository,
                                  warehouseSqLiteRepository,
                                  warehouseTranslator,
                                  _unitOfWorkFactory, bathSize)
                            : new SynchronizationCommand
                                  <WarehouseDto, Warehouse>(
                                  warehouseDtoRepository,
                                  warehouseSqLiteRepository,
                                  warehouseTranslator,
                                  _unitOfWorkFactory, bathSize,
                                  _viewModel
                                      .LastSynchronizationDate);

                    warehouseSyncCommand = warehouseSyncCommand.RepeatOnError(3, 5000);
                    warehouseSyncCommand.Execute();
                    Notify(new ProgressNotification(45));

                    // Price lists synchronization
                    Notify(new TextNotification("Price lists synchronization"));
                    var priceListDtoRepository = new WebRepository<PriceListDto>(webServer);
                    var priceListSqLiteRepository =
                        _repositoryFactory.CreateRepository<PriceList>();
                    DtoTranslator<PriceList, PriceListDto> priceListTranslator =
                        new PriceListTranslator(_repositoryFactory);

                    Command<bool> priceListSyncCommand =
                        _viewModel.SynchronizeFully
                            ? new SynchronizationCommand
                                  <PriceListDto, PriceList>(
                                  priceListDtoRepository,
                                  priceListSqLiteRepository,
                                  priceListTranslator,
                                  _unitOfWorkFactory, bathSize)
                            : new SynchronizationCommand
                                  <PriceListDto, PriceList>(
                                  priceListDtoRepository,
                                  priceListSqLiteRepository,
                                  priceListTranslator,
                                  _unitOfWorkFactory, bathSize,
                                  _viewModel
                                      .LastSynchronizationDate);

                    priceListSyncCommand = priceListSyncCommand.RepeatOnError(3, 5000);
                    priceListSyncCommand.Execute();
                    Notify(new ProgressNotification(52));

                    // UnitOfMeasures synchronization
                    Notify(new TextNotification("UnitOfMeasures synchronization"));
                    var unitOfMeasureDtoRepository = new WebRepository<UnitOfMeasureDto>(webServer);
                    var unitOfMeasureSqLiteRepository =
                        _repositoryFactory.CreateRepository<UnitOfMeasure>();
                    DtoTranslator<UnitOfMeasure, UnitOfMeasureDto> unitOfMeasureTranslator =
                        new UnitOfMeasureTranslator();

                    Command<bool> unitOfMeasureSyncCommand =
                        _viewModel.SynchronizeFully
                            ? new SynchronizationCommand
                                  <UnitOfMeasureDto,
                                  UnitOfMeasure>(
                                  unitOfMeasureDtoRepository,
                                  unitOfMeasureSqLiteRepository,
                                  unitOfMeasureTranslator,
                                  _unitOfWorkFactory,
                                  bathSize)
                            : new SynchronizationCommand
                                  <UnitOfMeasureDto,
                                  UnitOfMeasure>(
                                  unitOfMeasureDtoRepository,
                                  unitOfMeasureSqLiteRepository,
                                  unitOfMeasureTranslator,
                                  _unitOfWorkFactory,
                                  bathSize,
                                  _viewModel
                                      .LastSynchronizationDate);

                    unitOfMeasureSyncCommand = unitOfMeasureSyncCommand.RepeatOnError(3, 5000);
                    unitOfMeasureSyncCommand.Execute();
                    Notify(new ProgressNotification(60));

                    // Products synchronization
                    Notify(new TextNotification("Products synchronization"));
                    var productDtoRepository = new WebRepository<ProductDto>(webServer);
                    var productSqLiteRepository =
                        _repositoryFactory.CreateRepository<Product>();
                    DtoTranslator<Product, ProductDto> productTranslator =
                        new ProductTranslator(_repositoryFactory);

                    Command<bool> productSyncCommand = _viewModel.SynchronizeFully
                                                     ? new SynchronizationCommand
                                                           <ProductDto, Product
                                                           >(
                                                           productDtoRepository,
                                                           productSqLiteRepository,
                                                           productTranslator,
                                                           _unitOfWorkFactory,
                                                           bathSize)
                                                     : new SynchronizationCommand
                                                           <ProductDto, Product
                                                           >(
                                                           productDtoRepository,
                                                           productSqLiteRepository,
                                                           productTranslator,
                                                           _unitOfWorkFactory,
                                                           bathSize,
                                                           _viewModel
                                                               .LastSynchronizationDate);
                    productSyncCommand = productSyncCommand.RepeatOnError(3, 5000);
                    productSyncCommand.Execute();
                    Notify(new ProgressNotification(67));

                    // Product prices synchronization
                    Notify(new TextNotification("Product prices synchronization"));
                    var productsPriceDtoRepository = new WebRepository<ProductPriceDto>(webServer);
                    var productsPriceSqLiteRepository =
                        _repositoryFactory.CreateRepository<ProductsPrice>();
                    DtoTranslator<ProductsPrice, ProductPriceDto> productsPriceTranslator =
                        new ProductsPriceTranslator();

                    Command<bool> productsPricesSyncCommand =
                        _viewModel.SynchronizeFully
                            ? new SynchronizationCommand
                                  <ProductPriceDto,
                                  ProductsPrice>(
                                  productsPriceDtoRepository,
                                  productsPriceSqLiteRepository,
                                  productsPriceTranslator,
                                  _unitOfWorkFactory,
                                  bathSize)
                            : new SynchronizationCommand
                                  <ProductPriceDto,
                                  ProductsPrice>(
                                  productsPriceDtoRepository,
                                  productsPriceSqLiteRepository,
                                  productsPriceTranslator,
                                  _unitOfWorkFactory,
                                  bathSize,
                                  _viewModel
                                      .LastSynchronizationDate);

                    productsPricesSyncCommand = productsPricesSyncCommand.RepeatOnError(3, 5000);
                    productsPricesSyncCommand.Execute();
                    Notify(new ProgressNotification(75));

                    // Product units of measure synchronization
                    Notify(new TextNotification("Product units of measure synchronization"));
                    var productsUomDtoRepository =
                        new WebRepository<ProductUnitOfMeasureDto>(webServer);
                    var productsUnitOfMeasureSqLiteRepository =
                        _repositoryFactory.CreateRepository<ProductsUnitOfMeasure>();
                    DtoTranslator<ProductsUnitOfMeasure, ProductUnitOfMeasureDto>
                        productsUnitOfMeasureTranslator =
                            new ProductsUnitOfMeasureTranslator();

                    Command<bool> productsUomSyncCommand =
                        _viewModel.SynchronizeFully
                            ? new SynchronizationCommand
                                  <ProductUnitOfMeasureDto, ProductsUnitOfMeasure>(
                                  productsUomDtoRepository, productsUnitOfMeasureSqLiteRepository,
                                  productsUnitOfMeasureTranslator,
                                  _unitOfWorkFactory, bathSize)
                            : new SynchronizationCommand
                                  <ProductUnitOfMeasureDto, ProductsUnitOfMeasure>(
                                  productsUomDtoRepository, productsUnitOfMeasureSqLiteRepository,
                                  productsUnitOfMeasureTranslator,
                                  _unitOfWorkFactory, bathSize,
                                  _viewModel.LastSynchronizationDate);

                    productsUomSyncCommand = productsUomSyncCommand.RepeatOnError(3, 5000);
                    productsUomSyncCommand.Execute();
                    Notify(new ProgressNotification(82));

                    // Route templates synchronization
                    Notify(new TextNotification("Route templates synchronization"));
                    var routeTemplateDtoRepository = new WebRepository<RouteTemplateDto>(webServer);
                    var routeTemplateSqLiteRepository =
                        _repositoryFactory.CreateRepository<RouteTemplate>();
                    DtoTranslator<RouteTemplate, RouteTemplateDto> routeTemplateTranslator =
                        new RouteTemplateTranslator(_repositoryFactory);

                    Command<bool> routeTemplateSyncCommand =
                        _viewModel.SynchronizeFully
                            ? new SynchronizationCommand
                                  <RouteTemplateDto,
                                  RouteTemplate>(
                                  routeTemplateDtoRepository,
                                  routeTemplateSqLiteRepository,
                                  routeTemplateTranslator,
                                  _unitOfWorkFactory,
                                  bathSize)
                            : new SynchronizationCommand
                                  <RouteTemplateDto,
                                  RouteTemplate>(
                                  routeTemplateDtoRepository,
                                  routeTemplateSqLiteRepository,
                                  routeTemplateTranslator,
                                  _unitOfWorkFactory,
                                  bathSize,
                                  _viewModel
                                      .LastSynchronizationDate);

                    routeTemplateSyncCommand = routeTemplateSyncCommand.RepeatOnError(3, 5000);
                    routeTemplateSyncCommand.Execute();
                    Notify(new ProgressNotification(90));

                    // Route points templates synchronization
                    Notify(new TextNotification("Route points templates synchronization"));
                    var routePointTemplateDtoRepository =
                        new WebRepository<RoutePointTemplateDto>(webServer);
                    var routePointTemplateSqLiteRepository =
                        _repositoryFactory.CreateRepository<RoutePointTemplate>();
                    DtoTranslator<RoutePointTemplate, RoutePointTemplateDto>
                        routePointTemplateTranslator =
                            new RoutePointTemplateTranslator();

                    Command<bool> routePointTemplateSyncCommand =
                        _viewModel.SynchronizeFully
                            ? new SynchronizationCommand
                                  <RoutePointTemplateDto, RoutePointTemplate>(
                                  routePointTemplateDtoRepository,
                                  routePointTemplateSqLiteRepository,
                                  routePointTemplateTranslator,
                                  _unitOfWorkFactory, bathSize)
                            : new SynchronizationCommand
                                  <RoutePointTemplateDto, RoutePointTemplate>(
                                  routePointTemplateDtoRepository,
                                  routePointTemplateSqLiteRepository,
                                  routePointTemplateTranslator,
                                  _unitOfWorkFactory, bathSize,
                                  _viewModel.LastSynchronizationDate);

                    routePointTemplateSyncCommand = routePointTemplateSyncCommand.RepeatOnError(3,
                                                                                                5000);
                    routePointTemplateSyncCommand.Execute();
                    Notify(new ProgressNotification(100));

                    // Managers settings synchronization
                    Notify(new TextNotification("Managers settings synchronization"));
                    warehouseSqLiteRepository =
                        _repositoryFactory.CreateRepository<Warehouse>();

                    Command<bool> managerSettingsSyncCommand =
                        _viewModel.SynchronizeFully
                            ? new ManagerSynchronization(
                                  webServer,
                                  warehouseSqLiteRepository,
                                  _unitOfWorkFactory)
                            : new ManagerSynchronization(
                                  webServer,
                                  warehouseSqLiteRepository,
                                  _unitOfWorkFactory,
                                  _viewModel
                                      .LastSynchronizationDate);

                    managerSettingsSyncCommand = managerSettingsSyncCommand.RepeatOnError(3, 5000);
                    managerSettingsSyncCommand.Execute();

                    // Settings synchronization
                    Notify(new TextNotification("Settings synchronization"));

                    Command<bool> settingsSyncCommand =
                        _viewModel.SynchronizeFully
                            ? new SettingsSynchronization(
                                  webServer, _configurationManager)
                            : new SettingsSynchronization(
                                  webServer,
                                  _configurationManager,
                                  _viewModel.LastSynchronizationDate);

                    settingsSyncCommand = settingsSyncCommand.RepeatOnError(3, 5000);
                    settingsSyncCommand.Execute();

                    _configurationManager.GetConfig("Common")
                                         .GetSection("Synchronization")
                                         .GetSetting("LastSyncDate").Value =
                        synchronizationDate.ToString(DateTimeFormatInfo.InvariantInfo);
                    _configurationManager.GetConfig("Common").Save();

                    _view.ShowInformation("Synchronization complete");
                }
            }
            catch (ThreadAbortException) {
            }
            catch (Exception exception) {
                Log.Error("Synchronization failed", exception);
                _view.ShowError(new[] {"Synchronization failed! Please, try to synchronize later."});
            }
            finally {
                _view.MakeActive();
                _inProcess = false;
            }

            _view.ReturnToMenu();
        }
        public void SynchronizeTest()
        {
            var webServer = new WebServer("http://mss.alkotorg.com", "manager", "423200");
            const int bathSize = 300;
            var storageManager = new SqLiteStorageManager();
            var unitOfWorkFactory = new SqLiteUnitOfWorkFactory(storageManager);

            // Initialization
            const string dbScriptFileName = @"\schema.sql";
            string databaseScriptFullPath = TestEnvironment.GetApplicationDirectory() + dbScriptFileName;
            string databaseFileFullPath = TestEnvironment.GetApplicationDirectory() + @"\storage.sqlite";
            var database = storageManager.CreateOrOpenStorage(databaseFileFullPath, databaseScriptFullPath);

            var repositoryFactory = new RepositoryFactory(storageManager);
            repositoryFactory.RegisterSpecificationTranslator(new CommonTranslator<Customer>())
                             .RegisterSpecificationTranslator(new ShippingAddressSpecTranslator())
                             .RegisterSpecificationTranslator(new CommonTranslator<Category>())
                             .RegisterSpecificationTranslator(new CommonTranslator<PriceList>())
                             .RegisterSpecificationTranslator(new CommonTranslator<Product>())
                             .RegisterSpecificationTranslator(new OrderSpecTranslator())
                             .RegisterSpecificationTranslator(new OrderItemSpecTranslator())
                             .RegisterSpecificationTranslator(new ProductPriceSpecTranslator())
                             .RegisterSpecificationTranslator(
                                 new ProductsUnitOfMeasureSpecTranslator())
                             .RegisterSpecificationTranslator(new RoutePointSpecTranslator())
                             .RegisterSpecificationTranslator(new RouteSpecTranslator())
                             .RegisterSpecificationTranslator(
                                 new RoutePointTemplateSpecTranslator())
                             .RegisterSpecificationTranslator(new RouteTemplateSpecTranslator())
                             .RegisterSpecificationTranslator(new CommonTranslator<Status>())
                             .RegisterSpecificationTranslator(new CommonTranslator<UnitOfMeasure>())
                             .RegisterSpecificationTranslator(new CommonTranslator<Warehouse>());

                // Customers synchronization
                var customerDtoRepository = new WebRepository<CustomerDto>(webServer);
                var customerSqLiteRepository = repositoryFactory.CreateRepository<Customer>();
                DtoTranslator<Customer, CustomerDto> customerTranslator =
                    new CustomerTranslator(repositoryFactory);

                var customerSyncCmd =
                    new SynchronizationCommand<CustomerDto, Customer>(customerDtoRepository,
                                                                      customerSqLiteRepository,
                                                                      customerTranslator, unitOfWorkFactory,
                                                                      bathSize);

                customerSyncCmd.Execute();

                // Shipping addresses synchronization
                var shippingAddressDtoRepository =
                    new WebRepository<ShippingAddressDto>(webServer);
                var shippingAddressSqLiteRepository = repositoryFactory.CreateRepository<ShippingAddress>();
                DtoTranslator<ShippingAddress, ShippingAddressDto> shippingAddressdTranslator =
                    new ShippingAddressdTranslator();

                var shippingAddressSyncCmd =
                    new SynchronizationCommand<ShippingAddressDto, ShippingAddress>(
                        shippingAddressDtoRepository, shippingAddressSqLiteRepository,
                        shippingAddressdTranslator, unitOfWorkFactory, bathSize);
                shippingAddressSyncCmd.Execute();

                // Categories synchronization
                var categoriesDtoRepository = new WebRepository<CategoryDto>(webServer);
                var categorySqLiteRepository = repositoryFactory.CreateRepository<Category>();
                DtoTranslator<Category, CategoryDto> categoriesTranslator = new CategoryTranslator();
                var categoriesSyncCmd = new CategotiesSynchronization(categoriesDtoRepository,
                                                                      categorySqLiteRepository,
                                                                      categoriesTranslator,
                                                                      unitOfWorkFactory, bathSize);

                categoriesSyncCmd.Execute();

                // Statuses synchronization
                var statusDtoRepository = new WebRepository<StatusDto>(webServer);
                var statusSqLiteRepository = repositoryFactory.CreateRepository<Status>();
                DtoTranslator<Status, StatusDto> statusTranslator = new StatusTranslator();

                var statusSyncCommand =
                    new SynchronizationCommand<StatusDto, Status>(statusDtoRepository,
                                                                  statusSqLiteRepository,
                                                                  statusTranslator, unitOfWorkFactory,
                                                                  bathSize);

                statusSyncCommand.Execute();

                // Warehouses synchronization
                var warehouseDtoRepository = new WebRepository<WarehouseDto>(webServer);
                var warehouseSqLiteRepository = repositoryFactory.CreateRepository<Warehouse>();
                DtoTranslator<Warehouse, WarehouseDto> warehouseTranslator =
                    new WarehouseTranslator();

                var warehouseSyncCommand =
                    new SynchronizationCommand<WarehouseDto, Warehouse>(warehouseDtoRepository,
                                                                        warehouseSqLiteRepository,
                                                                        warehouseTranslator,
                                                                        unitOfWorkFactory, bathSize);

                warehouseSyncCommand.Execute();

                // Price lists synchronization
                var priceListDtoRepository = new WebRepository<PriceListDto>(webServer);
                var priceListSqLiteRepository = repositoryFactory.CreateRepository<PriceList>();
                DtoTranslator<PriceList, PriceListDto> priceListTranslator =
                    new PriceListTranslator(repositoryFactory);

                var priceListSyncCommand =
                    new SynchronizationCommand<PriceListDto, PriceList>(priceListDtoRepository,
                                                                        priceListSqLiteRepository,
                                                                        priceListTranslator,
                                                                        unitOfWorkFactory, bathSize);

                priceListSyncCommand.Execute();

                // UnitOfMeasures synchronization
                var unitOfMeasureDtoRepository =
                    new WebRepository<UnitOfMeasureDto>(webServer);
                var unitOfMeasureSqLiteRepository = repositoryFactory.CreateRepository<UnitOfMeasure>();
                DtoTranslator<UnitOfMeasure, UnitOfMeasureDto> unitOfMeasureTranslator =
                    new UnitOfMeasureTranslator();

                var unitOfMeasureSyncCommand =
                    new SynchronizationCommand<UnitOfMeasureDto, UnitOfMeasure>(
                        unitOfMeasureDtoRepository, unitOfMeasureSqLiteRepository,
                        unitOfMeasureTranslator, unitOfWorkFactory, bathSize);

                unitOfMeasureSyncCommand.Execute();

                // Products synchronization
                var productDtoRepository = new WebRepository<ProductDto>(webServer);
                var productSqLiteRepository = repositoryFactory.CreateRepository<Product>();
                DtoTranslator<Product, ProductDto> productTranslator = new ProductTranslator(repositoryFactory);

                var productSyncCommand =
                    new SynchronizationCommand<ProductDto, Product>(productDtoRepository,
                                                                    productSqLiteRepository,
                                                                    productTranslator, unitOfWorkFactory,
                                                                    bathSize);

                productSyncCommand.Execute();

                // Product prices synchronization
                var productsPriceDtoRepository =
                    new WebRepository<ProductPriceDto>(webServer);
                var productsPriceSqLiteRepository = repositoryFactory.CreateRepository<ProductsPrice>();
                DtoTranslator<ProductsPrice, ProductPriceDto> productsPriceTranslator =
                    new ProductsPriceTranslator();

                var productsPricesSyncCommand =
                    new SynchronizationCommand<ProductPriceDto, ProductsPrice>(
                        productsPriceDtoRepository, productsPriceSqLiteRepository,
                        productsPriceTranslator, unitOfWorkFactory, bathSize);

                productsPricesSyncCommand.Execute();

                // Product units of measure synchronization
                var productsUomDtoRepository =
                    new WebRepository<ProductUnitOfMeasureDto>(webServer);
                var productsUnitOfMeasureSqLiteRepository =
                    repositoryFactory.CreateRepository<ProductsUnitOfMeasure>();
                DtoTranslator<ProductsUnitOfMeasure, ProductUnitOfMeasureDto>
                    productsUnitOfMeasureTranslator = new ProductsUnitOfMeasureTranslator();

                var productsUomSyncCommand =
                    new SynchronizationCommand<ProductUnitOfMeasureDto, ProductsUnitOfMeasure>(
                        productsUomDtoRepository, productsUnitOfMeasureSqLiteRepository,
                        productsUnitOfMeasureTranslator, unitOfWorkFactory, bathSize);

                productsUomSyncCommand.Execute();

                // Route templates synchronization
                var routeTemplateDtoRepository =
                    new WebRepository<RouteTemplateDto>(webServer);
                var routeTemplateSqLiteRepository = repositoryFactory.CreateRepository<RouteTemplate>();
                DtoTranslator<RouteTemplate, RouteTemplateDto> routeTemplateTranslator =
                    new RouteTemplateTranslator(repositoryFactory);

                var routeTemplateSyncCommand =
                    new SynchronizationCommand<RouteTemplateDto, RouteTemplate>(
                        routeTemplateDtoRepository, routeTemplateSqLiteRepository,
                        routeTemplateTranslator, unitOfWorkFactory, bathSize);

                routeTemplateSyncCommand.Execute();

                // Route points templates synchronization
                var routePointTemplateDtoRepository =
                    new WebRepository<RoutePointTemplateDto>(webServer);
                var routePointTemplateSqLiteRepository =
                    repositoryFactory.CreateRepository<RoutePointTemplate>();
                DtoTranslator<RoutePointTemplate, RoutePointTemplateDto>
                    routePointTemplateTranslator = new RoutePointTemplateTranslator();

                var routePointTemplateSyncCommand =
                    new SynchronizationCommand<RoutePointTemplateDto, RoutePointTemplate>(
                        routePointTemplateDtoRepository, routePointTemplateSqLiteRepository,
                        routePointTemplateTranslator, unitOfWorkFactory, bathSize);

                routePointTemplateSyncCommand.Execute();

            // Copy result database
            File.Copy(databaseFileFullPath, @"\Storage Card\storage.sqlite");
            database.Dispose();
        }