public HttpResponseMessage GetEmpty(string id) { try { id = "SuppRigidi"; PapiroService papiro = new PapiroService(); //work with product Product prod = papiro.InitProduct(id, new ProductTaskNameRepository(), new FormatsNameRepository(), new TypeOfTaskRepository()); return Request.CreateResponse<Product>(HttpStatusCode.OK, prod); } catch (Exception) { return Request.CreateResponse(HttpStatusCode.InternalServerError); } }
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); }
public async Task<ActionResult> CreateProduct(string id) { var p = new PapiroService(); p.ProductRepository = productRepository; p.CurrentDatabase = CurrentDatabase; var inizio = DateTime.Now; var c = p.InitProduct(id, prodTskNameRepository, formatsRepository, typeOfTaskRepository); var d = new ProductViewModel(); //controllo i dati di cliente e riferimento //cercando la session if (Session["CodDocument"] != null) { var doc = documentRepository.GetSingle((string)Session["CodDocument"]); d.DocumentName = doc.DocumentName; d.Customer = doc.Customer; } d.Product = c; // d.Quantities.Add(0); //view name is needed for reach right view because to using more than one submit we have to use "Action" in action method name ViewBag.ActionMethod = "CreateProduct"; var tempo = DateTime.Now.Subtract(inizio); Console.WriteLine(tempo); return View("CreateProduct", d); }
public HttpResponseMessage GetPriceRigidBind([ModelBinder(typeof(ProductApiModelBinder))]ProductApi prod) { try { PapiroService papiro = new PapiroService(); //Initialize new product PapiroMVC.Models.ProductRigid prodIntero = (ProductRigid)papiro.InitProduct(prod.Id, new ProductTaskNameRepository(), new FormatsNameRepository(), new TypeOfTaskRepository()); Projection.ResolveProjection((ProductRigidApi)prod, prodIntero); //generazione dei prezzi a caso prod.Prices.Clear(); prod.Prices.Add(new Price { Date = DateTime.Today.AddDays(2), UnitPrice = "0.087" }); prod.Prices.Add(new Price { Date = DateTime.Today.AddDays(4), UnitPrice = "0.059" }); prod.Prices.Add(new Price { Date = DateTime.Today.AddDays(9), UnitPrice = "0.024" }); return Request.CreateResponse<ProductRigidApi>(HttpStatusCode.OK, (ProductRigidApi)prod); } catch (Exception) { return Request.CreateResponse(HttpStatusCode.InternalServerError); } }
public HttpResponseMessage GetEmptyRigid(string id) { try { PapiroService papiro = new PapiroService(); //Initialize new product PapiroMVC.Models.ProductRigid prodIntero = (ProductRigid)papiro.InitProduct(id, new ProductTaskNameRepository(), new FormatsNameRepository(), new TypeOfTaskRepository()); var prod = new ProductRigidApi(); prod.Id = id; Projection.MakeProjection(prodIntero, prod); return Request.CreateResponse<ProductRigidApi>(HttpStatusCode.OK, prod); } catch (Exception) { return Request.CreateResponse(HttpStatusCode.InternalServerError); } }