public ActionResult SaveCostDetail(string optCod = "") { disposable = false; CostDetail cv = (CostDetail)Session["CostDetail" + optCod]; PapiroService p = new PapiroService(); p.DocumentRepository = documentRepository;//new DocumentRepository(); p.CostDetailRepository = costDetailRepository; p.TaskExecutorRepository = taskExecutorRepository; p.ArticleRepository = articleRepository; p.TypeOfTaskRepository = typeOfTaskRepository; p.CurrentDatabase = CurrentDatabase; p.InitCostDocumentProduct(costDetailRepository.GetSingle(cv.CodCost).TaskCost.CodDocumentProduct); var cvRet = p.SaveCostDetailFromController(cv); var idRet = (string)Session["codProduct"]; Session["CostDetail" + optCod] = cvRet; disposable = true; if (idRet != null) { return Json(new { redirectUrl = Url.Action("EditDocumentProducts", new { id = idRet }) }, JsonRequestBehavior.AllowGet); } else { return Json(new { redirectUrl = Url.Action("Index", new { area = "" }) }, JsonRequestBehavior.AllowGet); } }
public ActionResult EditCost(string id) { var cd = costDetailRepository.GetSingle(id); if (cd == null) { var cost = documentRepository.GetCost(id); EditAndCreateAllCost(cost.CodDocumentProduct); cd = costDetailRepository.GetSingle(id); } PapiroService p = new PapiroService(); p.DocumentRepository = documentRepository;//new DocumentRepository(); p.CostDetailRepository = costDetailRepository; p.TaskExecutorRepository = taskExecutorRepository; p.ArticleRepository = articleRepository; p.TypeOfTaskRepository = typeOfTaskRepository; p.CurrentDatabase = CurrentDatabase; p.InitCostDocumentProduct(cd.TaskCost.CodDocumentProduct); var cv = p.EditCostAutomatically(id, new Guid()); //Console.WriteLine(cv.GainForRun); if (cv == null) { return View("NotImplementedCostDetail"); } Session["CostDetail"] = cv; Session["PapiroService"] = p; Console.Write(cv.Error); var viewName = String.Empty; switch (cv.TypeOfCostDetail) { case CostDetail.CostDetailType.PrintingZRollCostDetail: case CostDetail.CostDetailType.PrintingFlatRollCostDetail: ((PrintingZRollCostDetail)cv).DieTollerance = 0.5; ((PrintingZRollCostDetail)cv).Dies = articleRepository.GetAll().OfType<Die>().ToList(); ((PrintingZRollCostDetail)cv).FuzzyAlgo(); viewName = "PrintingCostDetail"; break; case CostDetail.CostDetailType.PrintingRollCostDetail: ((PrintingRollCostDetail)cv).FuzzyAlgo(); viewName = "PrintingCostDetail"; break; case CostDetail.CostDetailType.PrintingSheetCostDetail: viewName = "PrintingCostDetail"; break; case CostDetail.CostDetailType.PrintedSheetArticleCostDetail: viewName = "PrintingCostDetail"; break; case CostDetail.CostDetailType.PrintedRollArticleCostDetail: viewName = "PrintingCostDetail"; break; case CostDetail.CostDetailType.ControlTableCostDetail: viewName = "ControlTableCostDetail"; break; case CostDetail.CostDetailType.PrePostPressCostDetail: case CostDetail.CostDetailType.ImplantMeshCostDetail: case CostDetail.CostDetailType.ImplantHotPrintingCostDetail: case CostDetail.CostDetailType.RepassRollCostDetail: //get ST codCost cv.CodPartPrintingCostDetail = p.DocumentRepository.GetCostsByCodDocumentProduct(cv.TaskCost.CodDocumentProduct).Where(y1 => y1.CodItemGraph == "ST").Select(z => z.CodCost); //if there is a ST if (cv.CodPartPrintingCostDetail != null) { //fix all links foreach (var item in cv.CodPartPrintingCostDetail) { var cv2 = p.CostDetailRepository.GetSingle(item); if (!cv.Printers.Select(x => x.CodCostDetail).Contains(cv2.CodCostDetail)) { cv.Printers.Add(cv2); cv2.InitCostDetail(taskExecutorRepository.GetAll(), articleRepository.GetAll()); } } } viewName = "PrintingCostDetail"; break; default: viewName = "ControlTableCostDetail"; break; } Session["CostDetail"] = cv; Session["PapiroService"] = p; return View(viewName, cv); }