Esempio n. 1
0
        public OrderViewModelBuilder(
            RequestModelAccessor requestModelAccessor,
            FieldDefinitionService fieldDefinitionService,
            LanguageService languageService,
            PaymentService paymentService,
            PageService pageServcie,
            UrlService urlService,
            ModuleECommerce moduleECommerce,
            SecurityToken securityToken,
            ProductModelBuilder productModelBuilder,
            VariantService variantService,
            UnitOfMeasurementService unitOfMeasurementService,
            OrganizationService organizationService,
            PersonStorage personStorage)
        {
            _requestModelAccessor   = requestModelAccessor;
            _fieldDefinitionService = fieldDefinitionService;
            _languageService        = languageService;
            _paymentService         = paymentService;
            _pageServcie            = pageServcie;
            _urlService             = urlService;

            _moduleECommerce          = moduleECommerce;
            _securityToken            = securityToken;
            _productModelBuilder      = productModelBuilder;
            _variantService           = variantService;
            _unitOfMeasurementService = unitOfMeasurementService;
            _organizationService      = organizationService;
            _personStorage            = personStorage;
        }
        public List <ProductModel> GetByPartialName(string name)
        {
            var productModels = new List <ProductModel>();

            foreach (var product in _repository.GetByName().Where(x => x.Name.Contains(name)))
            {
                productModels.Add(ProductModelBuilder.Create(product));
            }
            return(productModels);
        }
Esempio n. 3
0
        private static IEnumerable <ProductModel> FakeProductModels()
        {
            var productModel = new ProductModelBuilder()
                               .WithProductName(TestProductName)
                               .Build();

            return(new List <ProductModel> {
                productModel
            });
        }
        public List <ProductModel> GetAllProducts()
        {
            var productModelList = new List <ProductModel>();

            foreach (var p in _repository.GetAll())
            {
                productModelList.Add(ProductModelBuilder.Create(p));
            }

            return(productModelList);
        }
Esempio n. 5
0
        public IHttpActionResult GetProduct(int id)
        {
            Product product = db.Products.Find(id);

            if (product == null)
            {
                return(NotFound());
            }

            return(Ok(ProductModelBuilder.create(product)));
        }
        public List <ProductModel> GetAllProductsByCategory(int id)
        {
            var productModelList = new List <ProductModel>();

            foreach (var prod in _repository.GetAll().Where(prod => prod.Category?.Id == id))
            {
                productModelList.Add(ProductModelBuilder.Create(prod));
            }

            return(productModelList);
        }
Esempio n. 7
0
 public ProductItemViewModelBuilder(RequestModelAccessor requestModelAccessor,
                                    ProductPriceModelBuilder productPriceModelBuilder,
                                    FieldDefinitionService fieldDefinitionService,
                                    StockService stockService,
                                    ProductModelBuilder productModelBuilder)
 {
     _requestModelAccessor     = requestModelAccessor;
     _productPriceModelBuilder = productPriceModelBuilder;
     _fieldDefinitionService   = fieldDefinitionService;
     _stockService             = stockService;
     _productModelBuilder      = productModelBuilder;
 }
 public ProductPageViewModelBuilder(
     ProductItemViewModelBuilder itemViewModelBuilder,
     RequestModelAccessor requestModelAccessor,
     ProductService productService,
     PageByFieldTemplateCache <BrandPageFieldTemplateCache> brandPageByFieldTypeCache,
     ProductFieldViewModelBuilder productFieldViewModelBuilder, ProductModelBuilder productModelBuilder)
 {
     _itemViewModelBuilder         = itemViewModelBuilder;
     _requestModelAccessor         = requestModelAccessor;
     _productService               = productService;
     _brandPageByFieldTypeCache    = brandPageByFieldTypeCache;
     _productFieldViewModelBuilder = productFieldViewModelBuilder;
     _productModelBuilder          = productModelBuilder;
 }
 public ProductBlockViewModelBuilder(ProductModelBuilder productModelBuilder,
                                     ProductItemViewModelBuilder productItemViewModelBuilder,
                                     RequestModelAccessor requestModelAccessor,
                                     ProductSearchService productSearchService,
                                     BaseProductService baseProductService,
                                     VariantService variantService)
 {
     _productModelBuilder         = productModelBuilder;
     _productItemViewModelBuilder = productItemViewModelBuilder;
     _requestModelAccessor        = requestModelAccessor;
     _productSearchService        = productSearchService;
     _baseProductService          = baseProductService;
     _variantService = variantService;
 }
 public SearchResultTransformationService(
     BaseProductService baseProductService,
     VariantService variantService,
     FieldDefinitionService fieldDefinitionService,
     ProductModelBuilder productModelBuilder,
     UrlService urlService,
     CategoryService categoryService)
 {
     _baseProductService     = baseProductService;
     _variantService         = variantService;
     _fieldDefinitionService = fieldDefinitionService;
     _productModelBuilder    = productModelBuilder;
     _urlService             = urlService;
     _categoryService        = categoryService;
 }
Esempio n. 11
0
        public ProductModel CreateProduct(ProductModel productC)
        {
            Product newProduct = new Product
            {
                Name            = productC.name,
                Description     = productC.description,
                Price           = productC.price,
                PublicationDate = DateTime.Now
            };


            newProduct.Category = _context.Categories.Single(c => c.Id == productC.categoryId);

            return(ProductModelBuilder.Create(_repository.Add(newProduct)));
        }
Esempio n. 12
0
        // GET: api/Products
        public IHttpActionResult GetProducts()
        {
            List <ProductModel> listOfProducts = new List <ProductModel>();

            foreach (var prod in db.Products)
            {
                ProductModel prodModel = ProductModelBuilder.create(prod);
                listOfProducts.Add(prodModel);
            }

            var jsonObj = new JavaScriptSerializer().Serialize(listOfProducts);

            if (jsonObj != null)
            {
                return(Ok(jsonObj));
            }
            return(NotFound());
        }
        private static IEnumerable <ProductModel> FakeProductModels()
        {
            var tofuProduct = new ProductModelBuilder()
                              .WithProductId(InMemoryDbEntitiesValues.TestTofuProductId)
                              .WithProductName(InMemoryDbEntitiesValues.TestTofuProductName)
                              .WithCategoryName(InMemoryDbEntitiesValues.TestSeafoodCategoryName)
                              .WithSupplierName(InMemoryDbEntitiesValues.TestSunnyDaySupplierName)
                              .Build();

            var changProduct = new ProductModelBuilder()
                               .WithProductId(InMemoryDbEntitiesValues.TestChangProductId)
                               .WithProductName(InMemoryDbEntitiesValues.TestChangProductName)
                               .WithCategoryName(InMemoryDbEntitiesValues.TestMeatCategoryName)
                               .WithSupplierName(InMemoryDbEntitiesValues.TestSunnyDaySupplierName)
                               .Build();

            return(new[] { tofuProduct, changProduct });
        }
 public ProductItemViewModelBuilder(RequestModelAccessor requestModelAccessor,
                                    ProductPriceModelBuilder productPriceModelBuilder,
                                    FieldDefinitionService fieldDefinitionService,
                                    StockService stockService,
                                    ProductModelBuilder productModelBuilder,
                                    CartContextAccessor cartContextAccessor,
                                    CurrencyService currencyService,
                                    CountryService countryService)
 {
     _requestModelAccessor     = requestModelAccessor;
     _productPriceModelBuilder = productPriceModelBuilder;
     _fieldDefinitionService   = fieldDefinitionService;
     _stockService             = stockService;
     _productModelBuilder      = productModelBuilder;
     _cartContextAccessor      = cartContextAccessor;
     _currencyService          = currencyService;
     _countryService           = countryService;
 }
Esempio n. 15
0
 public ProductSearchServiceImpl(
     SearchService searchService,
     ProductModelBuilder productModelBuilder,
     BaseProductService baseProductService,
     VariantService variantService,
     FieldDefinitionService fieldDefinitionService,
     UrlService urlService,
     RequestModelAccessor requestModelAccessor,
     SearchQueryBuilderFactory searchQueryBuilderFactory,
     CategoryService categoryService)
 {
     _productModelBuilder       = productModelBuilder;
     _baseProductService        = baseProductService;
     _variantService            = variantService;
     _fieldDefinitionService    = fieldDefinitionService;
     _urlService                = urlService;
     _requestModelAccessor      = requestModelAccessor;
     _searchService             = searchService;
     _searchQueryBuilderFactory = searchQueryBuilderFactory;
     _categoryService           = categoryService;
 }
Esempio n. 16
0
        public ProductModel ModifyProduct(ProductModel productU)
        {
            if (_repository.GetById(productU.id) == null)
            {
                throw new ArgumentException("Le produit est introuvable.");
            }

            var productToUpdate = new Product
            {
                Id              = productU.id,
                Name            = productU.name,
                Price           = productU.price,
                PublicationDate = DateTime.Now,
                Description     = productU.description,
                Category        = new Category {
                    Id = productU.categoryId
                }
            };

            return(ProductModelBuilder.Create(_repository.Update(productToUpdate)));
        }
        public OrderViewModelBuilder(
            RequestModelAccessor requestModelAccessor,
            FieldDefinitionService fieldDefinitionService,
            PageService pageServcie,
            UrlService urlService,
            ProductModelBuilder productModelBuilder,
            VariantService variantService,
            UnitOfMeasurementService unitOfMeasurementService,
            OrganizationService organizationService,
            PersonStorage personStorage,
            OrderOverviewService orderOverviewService,
            ChannelService channelService,
            CurrencyService currencyService,
            ShippingProviderService shippingProviderService,
            StateTransitionsService stateTransitionsService,
            CountryService countryService,
            OrderHelperService orderHelperService)
        {
            _requestModelAccessor   = requestModelAccessor;
            _fieldDefinitionService = fieldDefinitionService;
            _pageServcie            = pageServcie;
            _urlService             = urlService;

            _productModelBuilder      = productModelBuilder;
            _variantService           = variantService;
            _unitOfMeasurementService = unitOfMeasurementService;
            _organizationService      = organizationService;
            _personStorage            = personStorage;
            _orderOverviewService     = orderOverviewService;
            _channelService           = channelService;
            _currencyService          = currencyService;
            _countryService           = countryService;
            _orderHelperService       = orderHelperService;
            _shippingProviderService  = shippingProviderService;
            _stateTransitionsService  = stateTransitionsService;
        }
 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     UserModelBuilder.BuildModel(modelBuilder);
     ProductModelBuilder.BuildModel(modelBuilder);
 }
Esempio n. 19
0
 public ProductModel GetProductById(int id)
 {
     return(ProductModelBuilder.Create(_repository.GetById(id)));
 }
Esempio n. 20
0
 public ProductModel GetProductByName(string name)
 {
     return(ProductModelBuilder.Create(_repository.GetSingle(x => x.Name == name)));
 }
 public ActionResult Edit(ProductModel product)
 {
     productService.Update(ProductModelBuilder.productModeltoProduct(product));
     return(View());
 }
 public ActionResult Create(ProductModel product)
 {
     productService.Insert(ProductModelBuilder.productModeltoProduct(product));
     return(View());
 }
Esempio n. 23
0
        static void Main(string[] args)
        {
            var serviceCollection = new ServiceCollection();
            var serviceProvider   = ServicesRegistry
                                    .Register(serviceCollection)
                                    .BuildServiceProvider();

            var dataSource = serviceProvider.GetService <IDataSourceService>();

            dataSource.Seed();

            var productRepository = serviceProvider.GetService <IProductRepository>();
            var receiptService    = serviceProvider.GetService <IReceiptService>();
            var printerService    = serviceProvider.GetService <IPrintService>();

            List <ProductModel> products = new List <ProductModel>();

            bool requestTotal = false;

            while (!requestTotal)
            {
                Console.WriteLine("Enter the product eg.(1 Book at 12.49):");
                string productDescription = Console.ReadLine();

                var result = ProductModelBuilder
                             .Get()
                             .WithProperties(productDescription)
                             .Build();

                if (!result.IsSuccess)
                {
                    Console.WriteLine($"There was an error trying to build the product: { result.Message }");
                    continue;
                }

                ProductModel product = productRepository.GetByName(result.Value.Description);
                product.Price = result.Value.Price;

                if (product == null)
                {
                    Console.WriteLine("Product not found");
                    continue;
                }

                products.Add(product);


                Console.WriteLine("Press (Esc) to finish or <Enter> to add an other product.");
                bool waitingForUser = true;
                while (waitingForUser)
                {
                    var key = Console.ReadKey();
                    if (key.Key == ConsoleKey.Escape)
                    {
                        waitingForUser = false;
                        requestTotal   = true;
                        continue;
                    }

                    if (key.Key == ConsoleKey.Enter)
                    {
                        waitingForUser = false;
                        continue;
                    }
                }
            }

            var receipt = receiptService.GenerateReceipt(products);

            printerService.Print(receipt);
        }