Example #1
0
 public OrdersController(IShopRepository shopRepository, ILogger <OrdersController> logger, IMapper mapper, UserManager <ShopUser> userManager)
 {
     this.repository  = shopRepository;
     this.logger      = logger;
     this.mapper      = mapper;
     this.userManager = userManager;
 }
Example #2
0
 public SearchMineShopsOperation(IShopRepository repository, IRequestBuilder requestBuilder, IHalResponseBuilder halResponseBuilder, IShopEnricher shopEnricher)
 {
     _repository         = repository;
     _requestBuilder     = requestBuilder;
     _halResponseBuilder = halResponseBuilder;
     _shopEnricher       = shopEnricher;
 }
Example #3
0
 public ShopController(IShopRepository shopRepository, IMessageModelBuilder messageModelBuilder, IMapper mapper, IWellRepository wellRepository)
 {
     _shopRepository      = shopRepository;
     _wellRepository      = wellRepository;
     _messageModelBuilder = messageModelBuilder;
     _mapper = mapper;
 }
Example #4
0
 public ShopController(
     IApplicationUserRepository userRepository,
     IShopRepository shopRepository)
 {
     _userRepository = userRepository;
     _shopRepository = shopRepository;
 }
Example #5
0
 public AuthController(IAuthRepository repo, IConfiguration config, IMapper mapper, IShopRepository shop)
 {
     _config = config;
     _repo   = repo;
     _mapper = mapper;
     _shop   = shop;
 }
Example #6
0
 public SearchShopCommentsOperation(IRequestBuilder requestBuilder, IHalResponseBuilder halResponseBuilder, IShopRepository shopRepository, IShopCommentEnricher commentEnricher)
 {
     _requestBuilder     = requestBuilder;
     _halResponseBuilder = halResponseBuilder;
     _shopRepository     = shopRepository;
     _commentEnricher    = commentEnricher;
 }
Example #7
0
        public ShopListAdapter(Context context, IShopRepository shopRepository)
        {
            _context        = IoC.MainContainer.Container.Resolve <Context>();
            _shopRepository = shopRepository;

            RefreshData();
        }
Example #8
0
        public ShopController(ICityRepository cityRepository, IShopRepository shopRepository, IConfigRepository configRepository,
                              IShopCategoryRefRepository shopCategoryRefRepository, ICatalogCategoryRepository catalogCategoryRepository,
                              ICatalogSecondCategoryRepository catalogSecondCategoryRepository, ICatalogThirdCategoryRepository catalogThirdCategoryRepository,
                              IProductRepository productRepository, IShopProductRefRepository shopProductRefRepository)
        {
            _cityRepository         = cityRepository;
            _cityRepository.Context = rc;

            _shopRepository         = shopRepository;
            _shopRepository.Context = rc;

            _configRepository         = configRepository;
            _configRepository.Context = rc;

            _shopCategoryRefRepository         = shopCategoryRefRepository;
            _shopCategoryRefRepository.Context = rc;

            _catalogCategoryRepository         = catalogCategoryRepository;
            _catalogCategoryRepository.Context = rc;

            _catalogSecondCategoryRepository         = catalogSecondCategoryRepository;
            _catalogSecondCategoryRepository.Context = rc;

            _catalogThirdCategoryRepository         = catalogThirdCategoryRepository;
            _catalogThirdCategoryRepository.Context = rc;

            _productRepository         = productRepository;
            _productRepository.Context = rc;

            _shopProductRefRepository         = shopProductRefRepository;
            _shopProductRefRepository.Context = rc;

            ViewBag.Slogan = ProjectConfiguration.Get.CatalogConfig.Slogan;
        }
Example #9
0
 public RetailDistributionUnitOfWork(IRetailDistributionContext context, IDistrictRepository districtRepository, IVendorRepository vendorRepository, IShopRepository shopRepository)
 {
     this.districtRepository = districtRepository;
     this.vendorRepository   = vendorRepository;
     this.shopRepository     = shopRepository;
     this.context            = context;
 }
Example #10
0
 public TestBLL()
 {
     shopRepo     = new ShopRepository(conn);
     businessRepo = new BusinessRepository(conn);
     imgRepo      = new ImagesRepository(conn);
     prodRepo     = new ProductRepository(conn);
     unitRepo     = new UnitRepository(conn);
     priceRepo    = new PriceRepository(conn);
     costRepo     = new CostRepository(conn);
     stockRepo    = new StockRepository(conn);
     userRepo     = new UserRepository(conn);
     billsRepo    = new BillsRepository(conn);
     expRepo      = new ExpensesRepository(conn);
     foldersRepo  = new FoldersRepository(conn);
     dbBase       = new DropBoxBase("o9340xsv2mzn7ws", "xzky2fzfnmssik1");
     checker      = new ShopsChecker(shopRepo);
     dbBase.GeneratedAuthenticationURL();
     dbBase.GenerateAccessToken();
     prodService = new ProductService(shopRepo, businessRepo, imgRepo, dbBase, prodRepo, unitRepo, priceRepo,
                                      costRepo, stockRepo, ordersRepo, strategy, new FoldersDataService(foldersRepo, prodRepo));
     orderStockRepo     = new OrderStockRepository(conn);
     strategy           = new FifoStrategy(orderStockRepo, stockRepo, costRepo);
     salesService       = new SalesSerivce(userRepo, shopRepo, billsRepo, prodRepo, priceRepo, imgRepo, strategy, checker, costRepo);
     ordersRepo         = new OrdersRepository(conn);
     productDataService = new ProductDataService(dbBase);
 }
 public ProductController(IProductRepository product, IMapper mapper
                          , IShopRepository shop)
 {
     _product = product;
     _mapper  = mapper;
     _shop    = shop;
 }
 public ShopController(IShopRepository shopRepository, IMapper mapper
                       , ILocation location)
 {
     _shopRepository = shopRepository;
     _mapper         = mapper;
     _location       = location;
 }
Example #13
0
        public SearchModel(IShopRepository repository, int langId, int? page, string categoryName = null, string productName = null, string articleName = null, string filter = null, string query = null, string sortOrder = null, string sortBy = null, bool showSpecialOffers = false)
            : base(repository, langId, "category", showSpecialOffers)
        {


            _repository = repository;

            IQueryable<Product> products = null;

            if (query != null && query.Length > 1)
            {
                products = _repository.GetProductsByQueryString(query).Where(p => p.ProductStocks.Any(ps => ps.IsAvailable));
            }
            else
            {
                products = _repository.GetProductsByCategory("");
            }

            switch (sortOrder)
            {
                case "desc":
                    products = products.OrderByDescending(p => p.Price).ThenBy(p => p.Name).AsQueryable();
                    break;
                case "asc":
                    products = products.OrderBy(p => p.Price).ThenBy(p => p.Name).AsQueryable();
                    break;
                default: // "abc"
                    products = products.OrderBy(p => p.Name).AsQueryable();
                    break;
            }


            var pageSize = int.Parse(SiteSettings.GetShopSetting("ProductsPageSize"));
            Products = products.Include(x => x.ProductAttributeValues)
                .Include(x => x.ProductImages)
                .ToList();

            ProductTotalCount = Products.Count();

            if (page > Products.Count() / pageSize)
            {
                page = 0;
            }

            Products = ApplyPaging(Products.AsQueryable(), page, pageSize).ToList();

            foreach (var product in Products)
            {
                product.CurrentLang = langId;
                if (product.ProductImages.Any())
                {
                    var pi = product.ProductImages.FirstOrDefault(c => c.IsDefault) ?? product.ProductImages.First();
                    product.ImageSource = pi.ImageSource;
                }
            }

            _sw.Stop();

            Log.DebugFormat("SiteModel+SearchModel: {0}", _sw.Elapsed);
        }
Example #14
0
        public ShopManager(
            IShopRepository repository,
            ILogger <ShopManager> logger,
            IHttpContextAccessor context,
            IOptions <ShopManagerOptions> optionsAccessor,
            IEnumerable <IShopValidator <Product> > prodValidators,
            IEnumerable <IShopValidator <Image> > imgValidators,
            IEnumerable <IShopValidator <Category> > catValidators,
            IEnumerable <IShopValidator <DescriptionGroup> > descGroupValidators,
            IEnumerable <IShopValidator <DescriptionGroupItem> > descGroupItemValidators,
            IEnumerable <IShopValidator <Description> > descValidators,
            IEnumerable <IShopValidator <Order> > orderValidators,
            IShopImageTransformer <Image> imgTransformer,
            OperationErrorDescriber errorDescriber = null)
        {
            _repository       = repository ?? throw new ArgumentNullException(nameof(repository));
            _logger           = logger ?? throw new ArgumentNullException(nameof(logger));
            ErrorDescriber    = errorDescriber ?? new OperationErrorDescriber();
            Options           = optionsAccessor.Value ?? new ShopManagerOptions();
            CancellationToken = context?.HttpContext?.RequestAborted ?? CancellationToken.None;

            //TODO create single validator class
            foreach (var validator in prodValidators)
            {
                ProductValidators.Add(validator);
            }

            foreach (var validator in imgValidators)
            {
                ImageValidators.Add(validator);
            }

            foreach (var validator in catValidators)
            {
                CategoryValidators.Add(validator);
            }

            foreach (var validator in descGroupValidators)
            {
                DescriptionGroupValidators.Add(validator);
            }

            foreach (var validator in descGroupItemValidators)
            {
                DescriptionGroupItemValidators.Add(validator);
            }

            foreach (var validator in descValidators)
            {
                DescriptionValidators.Add(validator);
            }

            foreach (var validator in orderValidators)
            {
                OrderValidators.Add(validator);
            }

            ImageTransformer = imgTransformer ??
                               new ShopImageTransformer(optionsAccessor);
        }
Example #15
0
        static Program()
        {
            AppDbContextFactory factory = new AppDbContextFactory();

            _appContext      = factory.CreateDbContext(null);
            _phoneRepository = new PhoneRepository(_appContext);
            _shopRepository  = new ShopRepository(_appContext);
        }
Example #16
0
 public HomeController(ICustomerRepository repository,
                       IPrefectureRepository prefectureRepository,
                       IShopRepository shopRepository)
 {
     this.repository           = repository;
     this.prefectureRepository = prefectureRepository;
     this.shopRepository       = shopRepository;
 }
Example #17
0
 public ShopConfigurationService(IShopRepository shopRepository)
 {
     if (shopRepository == null)
     {
         throw new ArgumentNullException(nameof(shopRepository));
     }
     _shopRepository = shopRepository;
 }
 public ComponentController(IComponentRepository componentRepository, IProviderRepository providerRepository, IShoppingCartRepository shoppingCartRepository, IShopRepository shopRepository, IShopStockRepository shopStockRepository)
 {
     IComponentRepository    = componentRepository;
     IProviderRepository     = providerRepository;
     IShoppingCartRepository = shoppingCartRepository;
     IShopRepository         = shopRepository;
     IShopStockRepository    = shopStockRepository;
 }
Example #19
0
 public AdministrationService(IProductRepository productRepository, IShopRepository shopRepository,
                              ICityRepository cityRepository, ICountryRepository countryRepository)
 {
     _shopRepository    = shopRepository;
     _countryRepository = countryRepository;
     _cityRepository    = cityRepository;
     _productRepository = productRepository;
 }
Example #20
0
        public AddPavilionToShopDialogFragment(DbHelper DAO, Pavilion pavilion)
        {
            pavilionRepository = DAO.CreateRepository <Pavilion>(pavilion.FloorId) as IPavilionRepository;
            shopRepository     = DAO.CreateRepository <Shop>(null) as IShopRepository;

            pavilionToUpdate = pavilion;
            shopToUpdate     = shopRepository.GetShopByPavilion(pavilion);
        }
Example #21
0
 public ProductPositionStrategy(IShopRepository shopRepository, IProductRepository productRepository, IStockRepository stockRepository, IOrdersRepository ordersRepository, IBillsRepository billsRepository)
 {
     _shopRepository    = shopRepository;
     _productRepository = productRepository;
     _stockRepository   = stockRepository;
     _ordersRepository  = ordersRepository;
     _billsRepository   = billsRepository;
 }
Example #22
0
 public CreateShop(
     IShopRepository shopRepo,
     IUnitOfWork uow
     )
 {
     _shopRepo = shopRepo;
     _uow      = uow;
 }
Example #23
0
 public CreateShopHandler(IMapper mapper,
                          IShopRepository shopRepository,
                          IFileService fileService)
 {
     _mapper         = mapper;
     _shopRepository = shopRepository;
     _fileService    = fileService;
 }
Example #24
0
 public ShopRegisterFragment(DbHelper DAO, Pavilion pavilion)
 {
     this.DAO       = DAO;
     shopRepository = DAO.CreateRepository <Shop>(null) as IShopRepository;
     pavilionRepository
                   = DAO.CreateRepository <Pavilion>(pavilion.FloorId) as IPavilionRepository;
     this.pavilion = pavilion;
 }
Example #25
0
 public PublishShop(
     IShopRepository shopRepo,
     IUnitOfWork uow
     )
 {
     _shopRepo = shopRepo;
     _uow      = uow;
 }
 public PrintBarcodeModel(IKaylaaRepository <Shop> shopRepo, IShopRepository shopspecificRepo,
                          IKaylaaRepository <Product> repo, IProductRepo prodSpecificRepo, IHttpContextAccessor httpContextAccessor)
 {
     this.shopRepo            = shopRepo;
     this.shopspecificRepo    = shopspecificRepo;
     this.repo                = repo;
     this.prodSpecificRepo    = prodSpecificRepo;
     this.httpContextAccessor = httpContextAccessor;
 }
Example #27
0
 public GetDisponibilityShop
 (
     IShopRepository shopRepo,
     IUtilDateTime utilDateTime
 )
 {
     _shopRepo     = shopRepo;
     _utilDateTime = utilDateTime;
 }
Example #28
0
 public ShopAppService(
     IShopRepository shopRepository,
     ISaleRepository saleRepository,
     IBookRepository inventoryRepository)
 {
     this.shopRepository      = shopRepository ?? throw new ArgumentNullException(nameof(shopRepository));
     this.saleRepository      = saleRepository ?? throw new ArgumentNullException(nameof(saleRepository));
     this.inventoryRepository = inventoryRepository ?? throw new ArgumentNullException(nameof(inventoryRepository));
 }
Example #29
0
 public ReceiveMaterialsHandler(IEntityRepository repository,
                                IShopRepository shopRepo, IInventoryService inventoryService,
                                IEventTransmitter eventTransmitter)
 {
     _repository       = repository;
     _shopRepo         = shopRepo;
     _inventoryService = inventoryService;
     _eventTransmitter = eventTransmitter;
 }
Example #30
0
 public GenericUnitOfWork(KoopDbContext koopDbContext, IMapper mapper, IAuthService authService)
 {
     _koopDbContext    = koopDbContext;
     _mapper           = mapper;
     _repositories     = new Dictionary <Type, object>();
     _repositoriesView = new Dictionary <Type, object>();
     _shopRepository   = new ShopRepository(_koopDbContext, mapper);
     _authService      = authService;
 }
Example #31
0
 public ShopMenuService(IUserRepository userRepository, ISlackWebApi slack, IItemRepository itemRepository, IShopService shopService, IGovernmentService governmentService, IShopRepository shopRepository)
 {
     _userRepository    = userRepository;
     _slack             = slack;
     _itemRepository    = itemRepository;
     _shopService       = shopService;
     _governmentService = governmentService;
     _shopRepository    = shopRepository;
 }
Example #32
0
        public SiteModel(IShopRepository repository, int langId, string contentName, bool showSpecialOffers = false, string articleName = null)
        {
            
            _sw.Start();


            Title = "Active Land";

            IQueryable<Category> categories = null;

            categories = repository.GetCategories().OrderBy(c => c.SortOrder);
            Categories = categories.Include(c => c.Children).ToList();

            //Categories = repository.GetCategories().Include(x=>x.Children).ToList();
            foreach (var category in Categories)
            {
                category.CurrentLang = langId;
            }

            if (showSpecialOffers)
                SpecialOffers = GetSpecialOffers(repository, langId, int.Parse(SiteSettings.GetShopSetting("SpecialOffersQuantity")));

            Contents = repository.GetContents();

            Content = contentName != null ? (contentName == "category" ? repository.GetCatalogueContent() : repository.GetContent(contentName)) : repository.GetContent();
            MainPageBanners = repository.GetMainPageBanners();
            SiteBanners = repository.GetSiteBanners().OrderBy(p => Guid.NewGuid()).Take(2).ToList();

            MainPageInfo = new MainPageInfo();
            var authorAvatarImageSource = repository.GetSiteProperty("AuthorAvatarImageSource");
            if (authorAvatarImageSource != null)
            {
                MainPageInfo.AuthorAvatarImageSource = authorAvatarImageSource.Value;
            }
            var authorGreetingText = repository.GetSiteProperty("AuthorGreetingText");
            if (authorGreetingText != null)
            {
                MainPageInfo.AuthorGreetingText = authorGreetingText.Value;
            }

            if (Content.ContentType == 2)
            {
                Articles = GetAllArticles(repository, langId);
            }

            LastArticles = GetLastArticles(repository, langId, int.Parse(SiteSettings.GetShopSetting("ArticlesQuantity")));
            QuickAdvices = repository.GetQuickAdvices(true);

            if (articleName != null)
            {
                this.Article = repository.GetArticle(articleName);
            }
           
        }
Example #33
0
        public ProductDetailsModel(IShopRepository repository, int langId, string productName, bool showSpecialOffers = false)
            : base(repository, langId, "category", showSpecialOffers)
        {
            _repository = repository;
            if (productName != null)
            {
                try
                {
                    Product = _repository.GetProduct(productName);
                    Product.IsInCart = WebSession.OrderItems.ContainsKey(Product.Id);
                }
                catch (ObjectNotFoundException)
                {
                    ErrorMessage = "Продукт не найден";
                }
            }

            _sw.Stop();

            Log.DebugFormat("SiteModel+ProductDetailsModel: {0}", _sw.Elapsed);
        }
Example #34
0
        public static string Execute(IShopRepository repository, int currentLangId, string categoryName)
        {


            var products = repository.GetProductsByCategory(categoryName).ToList();
            var attributes = repository.GetProductAttributes(categoryName).ToList();

            foreach (var productAttribute in attributes)
            {
                productAttribute.CurrentLang = currentLangId;
            }

            var sb = new StringBuilder();


            // Генерация заголовков begin
            var productFields = TransferData.ProductFields;

            foreach (var field in productFields)
            {
                sb.Append(field.Key);
                sb.Append(";");
            }

            int attrCnt = 0;
            foreach (var productAttribute in attributes)
            {
                attrCnt++;
                sb.Append(productAttribute.ExternalId);
                if (attrCnt != attributes.Count())
                    sb.Append(";");
            }

            sb.Append("\r\n");

            foreach (var field in productFields)
            {
                sb.Append(field.Value);
                sb.Append(";");
            }

            attrCnt = 0;
            foreach (var productAttribute in attributes)
            {
                attrCnt++;
                sb.Append(productAttribute.Title);
                if (attrCnt != attributes.Count())
                    sb.Append(";");
            }
            sb.Append("\r\n");
            // Генерация заголовков end


            foreach (var product in products)
            {
                product.CurrentLang = currentLangId;

                sb.Append(product.ExternalId);
                sb.Append(";");
                sb.Append(product.Name);
                sb.Append(";");
                sb.Append(product.Title);
                sb.Append(";");
                sb.Append(product.OldPrice);
                sb.Append(";");
                sb.Append(product.Price);
                sb.Append(";");
                sb.Append(product.IsNew);
                sb.Append(";");
                sb.Append(product.IsDiscount);
                sb.Append(";");
                sb.Append(product.IsTopSale);
                sb.Append(";");
                sb.Append(product.IsActive);
                sb.Append(";");
                sb.Append(product.SeoDescription);
                sb.Append(";");
                sb.Append(product.SeoKeywords);
                sb.Append(";");
                sb.Append(product.SeoText);
                sb.Append(";");
                sb.Append(!string.IsNullOrEmpty(product.Description)
                        ? product.Description.Replace("\n", " ").Replace(";","")
                        : product.Description);
                sb.Append(";");




                var firstProductStock = product.ProductStocks.OrderBy(ps => ps.StockNumber).FirstOrDefault();
                if (firstProductStock != null)
                {

                    sb.Append(firstProductStock.StockNumber);
                    sb.Append(";");
                    sb.Append(firstProductStock.Size);
                    sb.Append(";");
                    sb.Append(firstProductStock.Color);
                    sb.Append(";");
                }
                else
                {
                    sb.Append(";");
                    sb.Append(";");
                    sb.Append(";");
                }




                attrCnt = 0;
                foreach (var productAttribute in attributes)
                {
                    attrCnt++;
                    var result = new List<string>();

                    foreach (var pav in product.ProductAttributeValues)
                    {
                        pav.CurrentLang = currentLangId;
                        if (productAttribute.ProductAttributeValues.Contains(pav))
                        {
                            result.Add(pav.Title);
                        }
                    }

                    var res = DataSynchronizationHelper.ConvertToStringWithSeparators(result);
                    if (res != null)
                    {
                        sb.Append(res);
                    }
                    if (attrCnt != attributes.Count())
                        sb.Append(";");
                }

                sb.Append("\r\n");




                foreach (var ps in product.ProductStocks.OrderBy(ps => ps.StockNumber).Skip(1))
                {
                    sb.Append(product.ExternalId);
                    sb.Append(";");
                    sb.Append(product.Name);
                    sb.Append(";");
                    sb.Append(product.Title);
                    sb.Append(";");
                    sb.Append(product.OldPrice);
                    sb.Append(";");
                    sb.Append(product.Price);
                    sb.Append(";");
                    sb.Append(product.IsNew);
                    sb.Append(";");
                    sb.Append(product.IsDiscount);
                    sb.Append(";");
                    sb.Append(product.IsTopSale);
                    sb.Append(";");
                    sb.Append(product.IsActive);
                    sb.Append(";");
                    sb.Append(product.SeoDescription);
                    sb.Append(";");
                    sb.Append(product.SeoKeywords);
                    sb.Append(";");
                    sb.Append(product.SeoText);
                    sb.Append(";");
                    sb.Append(!string.IsNullOrEmpty(product.Description)
                        ? product.Description.Replace("\n", " ").Replace(";", "")
                        : product.Description);
                    sb.Append(";");



                    sb.Append(ps.StockNumber);
                    sb.Append(";");
                    sb.Append(ps.Size);
                    sb.Append(";");
                    sb.Append(ps.Color);
                    sb.Append(";");

                    attrCnt = 0;
                    foreach (var productAttribute in attributes)
                    {
                        attrCnt++;
                        var result = new List<string>();

                        foreach (var pav in product.ProductAttributeValues)
                        {
                            pav.CurrentLang = currentLangId;
                            if (productAttribute.ProductAttributeValues.Contains(pav))
                            {
                                result.Add(pav.Title);
                            }
                        }

                        var res = DataSynchronizationHelper.ConvertToStringWithSeparators(result);
                        if (res != null)
                        {
                            sb.Append(res);
                        }
                        if (attrCnt != attributes.Count())
                            sb.Append(";");
                    }

                    sb.Append("\r\n");

                }


            }

            return sb.ToString();
        }
Example #35
0
        public MainPageInfoController(IShopRepository repository) : base(repository)
        {

        }
Example #36
0
 public ArticleController(IShopRepository repository)
     : base(repository)
 {
 }
 public BaseApiController(IShopRepository repo)
 {
     _repo = repo;
 }
Example #38
0
        public static ImportResult Execute(IShopRepository repository, StreamReader file, string categoryName, int currentLangId)
        {

            Log.DebugFormat("start importing products Execute");
            var res = new ImportResult { ErrorCode = 0, ProductErrors = new Dictionary<string, string>() };
            //var products = new List<ImportedProduct>();
            try
            {
                bool justAdded = false;
                int productCount = 0;

                Log.DebugFormat("read products from file");
                List<ImportedProduct> products = ReadProductsFromFile(file);
                var importedProductsCount = products.Count();
                Log.DebugFormat("total products {0}", importedProductsCount);

                var productStockToDelete = new List<int>();
                foreach (var importedProduct in products)
                {
                    productCount++;
                    if (string.IsNullOrEmpty(importedProduct.ExternalId))
                    {
                        res.ReadProductFailedCount++;
                        continue;
                    }



                    Log.DebugFormat("get product {0} of {1}", productCount, importedProductsCount);
                    var siteProduct = repository.GetProductByExternalId(importedProduct.ExternalId);

                    if (siteProduct == null)
                    {
                        try
                        {
                            // добавляем новый товар
                            var category = repository.GetCategory(categoryName);
                            var newProduct = new Product { Category = category };
                            newProduct.InjectFromImportProduct(importedProduct);
                            if (importedProduct.ImportedProductStocks != null)
                            {
                                foreach (var importedProductStock in importedProduct.ImportedProductStocks)
                                {
                                    newProduct.ProductStocks.Add(new ProductStock
                                    {
                                        StockNumber = importedProductStock.StockNumber,
                                        Color = importedProductStock.Color,
                                        Size = importedProductStock.Size,
                                        IsAvailable = importedProductStock.IsAvailable
                                    });

                                }
                            }
                            newProduct.SearchCriteriaAttributes = "";
                            repository.AddProduct(newProduct);
                            justAdded = true;
                            res.NewProductCount++;

                            //Log.Debug("get site product again");
                            siteProduct = repository.GetProductByExternalId(importedProduct.ExternalId);
                        }
                        catch (Exception ex)
                        {
                            res.ProductErrors.Add("Не удалось добавить " + importedProduct.ExternalId, ex.Message);
                            res.AddProductFailedCount++;

                            //Log.ErrorFormat("cannot add new product externalId:{0} exception message:{1}", importedProduct.ExternalId, ex.Message);
                        }
                    }




                    if (siteProduct != null)
                    {
                        try
                        {
                            siteProduct.InjectFromImportProduct(importedProduct);
                            if (siteProduct.ProductStocks == null)
                            {
                                siteProduct.ProductStocks = new LinkedList<ProductStock>();
                            }


                            //Log.DebugFormat("Updating product stocks started");
                            foreach (var productStock in siteProduct.ProductStocks)
                            {
                                var importedProductStock =
                                    importedProduct.ImportedProductStocks.FirstOrDefault(
                                        ips => ips.StockNumber == productStock.StockNumber && !ips.Imported);
                                if (importedProductStock != null)
                                {
                                    // update productStock in siteProduct.ProductStocks
                                    importedProductStock.Imported = true;
                                    productStock.Size = importedProductStock.Size;
                                    productStock.Color = importedProductStock.Color;
                                    productStock.IsAvailable = importedProductStock.IsAvailable;
                                    res.UpdatedArticles++;
                                }
                                else
                                {
                                    // remove productStock from siteProduct.ProductStocks
                                    //repository.DeleteProductStock(productStock.Id);
                                    productStockToDelete.Add(productStock.Id);
                                    res.DeletedArticles++;
                                }
                            }



                            foreach (
                                var importedProductStock in
                                    importedProduct.ImportedProductStocks.Where(ips => !ips.Imported))
                            {
                                siteProduct.ProductStocks.Add(new ProductStock
                                {
                                    StockNumber = importedProductStock.StockNumber,
                                    Color = importedProductStock.Color,
                                    Size = importedProductStock.Size,
                                    IsAvailable = importedProductStock.IsAvailable
                                });
                                res.AddedArticles++;
                            }
                            //Log.DebugFormat("Updating product stocks finished");


                            //Log.DebugFormat("Updating product attributes started");
                            foreach (var attributeGroup in importedProduct.ImportedProductAttibutes)
                            {
                                var attrToDelete = new List<int>();
                                var exId = attributeGroup.ExternalId;
                                //Log.DebugFormat("get site attr started");
                                var siteAttr =
                                    siteProduct.ProductAttributeValues.Where(
                                        pav => pav.ProductAttribute.ExternalId == exId).Select(a => a.Title).ToList();
                                //Log.DebugFormat("get site attr finished");

                                var xx = siteAttr.Except(attributeGroup.Values).ToList(); //  items to delete
                                var xy = attributeGroup.Values.Except(siteAttr).ToList(); //  items to add

                                List<string> addedAttr = new List<string>();

                                //Log.DebugFormat("get attr to delete started");
                                foreach (
                                    var attr in
                                        siteProduct.ProductAttributeValues.Where(
                                            pav => pav.ProductAttribute.ExternalId == exId))
                                {
                                    if (xx.Contains(attr.Title))
                                    {
                                        attrToDelete.Add(attr.Id);
                                    }
                                }
                                //Log.DebugFormat("get attr to delete finished");

                                //Log.DebugFormat("ProductAttributeValues.Remove started");
                                foreach (var id in attrToDelete)
                                {
                                    var a = repository.GetProductAttributeValue(id);
                                    siteProduct.ProductAttributeValues.Remove(a);
                                }
                                //Log.DebugFormat("ProductAttributeValues.Remove finished");

                                //Log.DebugFormat("repository.GetProductAttributes(siteProduct.CategoryId) started");
                                var productAttributes = repository.GetProductAttributes(siteProduct.CategoryId);
                                //Log.DebugFormat("repository.GetProductAttributes(siteProduct.CategoryId) finished");


                                //Log.DebugFormat("siteProduct.ProductAttributeValues.Add(attributeValue) started");
                                var productAttribute = productAttributes.FirstOrDefault(pa => pa.ExternalId == exId);
                                if (productAttribute == null)
                                {
                                    //Log.ErrorFormat("Атрибут с идентификатором {0} не найден", exId);
                                    throw new Exception("Атрибут с идентификатором " + exId + " не найден");
                                }
                                foreach (var attributeValue in productAttribute.ProductAttributeValues)
                                {
                                    if (xy.Contains(attributeValue.Title))
                                    {
                                        siteProduct.ProductAttributeValues.Add(attributeValue);
                                        addedAttr.Add(attributeValue.Title);
                                    }
                                }
                                //Log.DebugFormat("siteProduct.ProductAttributeValues.Add(attributeValue) finished");


                                //Log.DebugFormat("add new attributes started");
                                var attrNotFoundOnSite = xy.Except(addedAttr);
                                foreach (string s in attrNotFoundOnSite)
                                {
                                    var newProductAttributeValue = new ProductAttributeValue
                                    {
                                        CurrentLang = currentLangId,
                                        Title = s,
                                        ProductAttribute = productAttribute,
                                    };
                                    newProductAttributeValue.Products.Add(siteProduct);

                                    repository.AddProductAttributeValue(newProductAttributeValue);
                                }
                                //Log.DebugFormat("add new attributes finished");

                            }
                            //Log.DebugFormat("Updating product attributes finished");



                            Log.DebugFormat("save product {0} of {1}", productCount, importedProductsCount);
                            repository.SaveProduct(siteProduct);

                            //Log.DebugFormat("product saved {0} of {1}", productCount, importedProductsCount);

                            if (!justAdded)
                            {
                                res.UpdatedProductCount++;
                            }
                            else
                            {
                                justAdded = false;
                            }
                        }
                        catch (OutOfMemoryException ex)
                        {

                            Log.ErrorFormat("cannot update product externalId:{0} exception message:{1} exception{2}", siteProduct.ExternalId, ex.Message, ex);
                            throw new Exception(ex.Message);
                        }
                        catch (Exception ex)
                        {
                            res.ProductErrors.Add("Не удалось обновить " + siteProduct.ExternalId, ex.Message);
                            res.UpdateProductFailedCount++;

                            Log.ErrorFormat("cannot update product externalId:{0} exception message:{1}", siteProduct.ExternalId, ex.Message);

                        }
                    }
                }

                //Log.DebugFormat("deleting product stocks");
                foreach (var id in productStockToDelete)
                {
                    repository.DeleteProductStock(id);
                }
                //Log.DebugFormat("product stocks deleted");

                res.ProductCount = products.Count;
            }
            catch (Exception ex)
            {
                Log.DebugFormat("error while importing products {1}", ex.Message);
                res.ErrorMessage = ex.Message;
                res.ErrorCode = 1;
            }

            //Log.DebugFormat("finish importing products Execute");

            return res;
        }
Example #39
0
        //
        // GET: /Admin/DataTrasfer/

        public DataTrasferController(IShopRepository repository)
            : base(repository)
        {
            
        }
Example #40
0
        public CartController(IShopRepository repository)
            : base(repository)
        {

        }
Example #41
0
 public PuzzleController(IPuzzleRepository puzzleRepository, IShopRepository shopRepository, IHostingEnvironment environment)
 {
     _puzzleRepository = puzzleRepository;
     _shopRepository = shopRepository;
     _environment = environment;
 }
 public NapiAdatokController(IShopRepository shopRepository)
 {
     _shopRepository = shopRepository;
 }
Example #43
0
 public ShopController(IShopRepository shopRepository, IHostingEnvironment environment)
 {
     _shopRepository = shopRepository;
     _environment = environment;
 }
Example #44
0
        //
        // GET: /Admin/ShopSetting/

        public ShopSettingController(IShopRepository repository) : base(repository)
        {

        }
Example #45
0
 public ProductController(IShopRepository repository)
     : base(repository)
 {
 }
Example #46
0
        public ContentItemController(IShopRepository repository) : base(repository)
        {

        }
Example #47
0
        //
        // GET: /Admin/Order/

        public OrderController(IShopRepository repository)
            : base(repository)
        {
        }
 public NapiAdatokController()
 {
     _shopRepository = new ShopRepository(new KiskerEntities());
 }
 public Locations(IShopRepository shopRepository)
 {
     _shopRepository = shopRepository;
 }
 public CartController(IShopRepository shopRepository)
 {
     _shopRepository = shopRepository;
 }
Example #51
0
 public DefaultController(IShopRepository repository)
 {
     _repository = repository;
 }
Example #52
0
 public Navigation(IAuthorizationService authz, IShopRepository shopRepository)
 {
     _authz = authz;
     _shopRepository = shopRepository;
 }
 public CartController()
 {
     _shopRepository = new ShopRepository(new KiskerEntities());
 }
Example #54
0
        public SiteBannerController(IShopRepository repository)
            : base(repository)
        {

        }
Example #55
0
        //
        // GET: /Admin/SiteProperty/

        public SitePropertyController(IShopRepository repository) : base(repository)
        {
        }
Example #56
0
 public HomeController(IShopRepository repository) : base(repository)
 {
 }
        //
        // GET: /Admin/MainPageBanner/

        public MainPageBannerController(IShopRepository repository) : base(repository)
        {

        }
Example #58
0
 public CartModel(IShopRepository repository, int langId, string contentName) : base(repository,langId, contentName)
 {
     
 }
 public ProductAttributeValueController(IShopRepository repository)
     : base(repository)
 {
 }
Example #60
0
 public AdminController(IShopRepository repository) : base(repository)
 {
     
 }