Beispiel #1
0
        public void EditProductJustDocument()
        {
            var inizio = DateTime.Now;

            IDocumentRepository docRep = new DocumentRepository();
            IProductRepository prodRep = new ProductRepository();

            PapiroService p = new PapiroService();
            p.DocumentRepository = docRep;
            p.CostDetailRepository = new CostDetailRepository();
            p.TaskExecutorRepository = new TaskExecutorRepository();
            p.ArticleRepository = new ArticleRepository();

            Document doc = docRep.GetEstimateEcommerce("000001");
            doc.EstimateNumber = "0";

            DocumentProduct dp = docRep.GetDocumentProductsByCodProduct("").FirstOrDefault();

            //work with product
            Product prod = p.InitProduct("SuppRigidi", new ProductTaskNameRepository(), new FormatsNameRepository(), new TypeOfTaskRepository());

            //------passaggio del prodotto inizializzato all'ecommerce o alla view
            prod.CodProduct = prodRep.GetNewCode(prod);
            prod.ProductParts.FirstOrDefault().Format = "15x21";
            prod.ProductParts.FirstOrDefault().SubjectNumber = 1;

            var art = prod.ProductParts.FirstOrDefault().ProductPartPrintableArticles.FirstOrDefault();

            #region Printable Article

            IArticleRepository artRep = new ArticleRepository();
            var artFormList = artRep.GetAll().OfType<RigidPrintableArticle>().FirstOrDefault();

            art.TypeOfMaterial = artFormList.TypeOfMaterial;
            art.NameOfMaterial = artFormList.NameOfMaterial;
            art.Weight = artFormList.Weight;
            art.Color = artFormList.Color;
            #endregion

            //------ritorno del prodotto modificato!!!!

            //rigenero
            prodRep.Add(prod);
            prodRep.Save();

            #region ViewModel
            ProductViewModel pv = new ProductViewModel();
            pv.Product = prod;
            //            prod.ProductCodeRigen();

            pv.Quantity = 10;
            #endregion

            p.EditOrCreateAllCost(dp.CodDocumentProduct);

            var fine = DateTime.Now.Subtract(inizio).TotalSeconds;

            Assert.IsTrue(fine < 4);
        }