Esempio n. 1
0
        private Product ToDomain(Entities.Models.Product product)
        {
            if (product == null)
            {
                return(null);
            }

            return(new Product(
                       product.Code,
                       product.Description,
                       product.Catalogs.Select(x => new LinkedCatalog(x.Code, x.Description)).ToArray()
                       ));
        }
Esempio n. 2
0
        public void AddProduct(string code, string description)
        {
            // Domain checks omitted for semplicity...

            var product = new Entities.Models.Product
            {
                Code        = code,
                Description = description
            };

            _dbContext.Products.Add(product);
            _dbContext.SaveChanges();
        }
Esempio n. 3
0
        public int Execute(ProductModel product)
        {
            var newProduct = new Entities.Models.Product
            {
                ProductName        = product.ProductName,
                Description        = product.Description,
                LinkPdfManual      = product.LinkPdfManual,
                Picture            = product.Picture,
                BrandId            = product.BrandId,
                MetricId           = product.MetricId,
                CategoryId         = product.CategoryId,
                LocationId         = product.LocationId,
                LowestPrice        = product.LowestPrice,
                LowestPricePerUnit = product.LowestPricePerUnit,
                LatestPrice        = product.LatestPrice,
                latestPricePerUnit = product.LatestPricePerUnit,
                QualityId          = product.QualityId,
                StatusId           = product.StatusId
            };

            _repo.Product.Create(newProduct);
            _repo.Save();
            return(newProduct.Id);
        }