public ActionResult CreateFlexo(string returnUrl) { ViewBag.ReturnUrl = returnUrl; ViewBag.ReturnCodTypeOfTask = "STAMPAETICHROTOLO_LIST"; //Load each type of base ViewBag.TypeOfTaskList = typeOfTaskRepository.GetAll().Where(y => y.CodCategoryOfTask == "STAMPA"); //this feature is needed when in the view there are more than one input (submit button) form //Action Method speci ViewBag.ActionMethod = "CreateFlexo"; var x = new Flexo(); x.FormatMin = "0x0"; x.FormatMax = "0x0"; // TODO: Elaborazione dell'array del tipo di lavorazione che può svolgere. x.CodTypeOfTask = "STAMPAETICHROTOLO"; return View(x); }
public ActionResult CreateFlexo(Flexo c, string returnUrl, string returnCodTypeOfTask) { if (ModelState.IsValid) { try { //if code is empty then sistem has to assign one // if (c.Article.CodArticle == null) { c.CodTaskExecutor = taskExecutorRepository.GetNewCode(c); /*------------------------------------- c.LithoSheetCuttedCost.CodArticle = c.Article.CodArticle; c.LithoSheetCuttedCost.CodArticleCost = c.Article.CodArticle + "_CTC"; c.LithoSheetPakedCost.CodArticle = c.Article.CodArticle; c.LithoSheetPakedCost.CodArticleCost = c.Article.CodArticle + "_PKC"; c.LithoSheetPalletCost.CodArticle = c.Article.CodArticle; c.LithoSheetPalletCost.CodArticleCost = c.Article.CodArticle + "_PLC"; /*/ } taskExecutorRepository.Add(c); taskExecutorRepository.Save(); //hooray it passed - go back to index return Json(new { redirectUrl = Url.Action(returnUrl, new { codTypeOfTask = returnCodTypeOfTask }) }); } catch (Exception ex) { ModelState.AddModelError(string.Empty, "Something went wrong. Message: " + ex.Message); } } ViewBag.ReturnUrl = returnUrl; ViewBag.ReturnCodTypeOfTask = returnCodTypeOfTask;//"STAMPAETICHROTOLO_LIST"; //Load each type of ????????????? ViewBag.TypeOfTaskList = typeOfTaskRepository.GetAll().Where(y => y.CodCategoryOfTask == "STAMPA"); //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 = "CreateFlexo"; return PartialView("_EditAndCreateFlexo", c); }
public ActionResult EditFlexo(Flexo c, string returnUrl, string returnCodTypeOfTask) { if (ModelState.IsValid) { try { //controllare le lastre!!!!!!!!!!!!!!!!!!!!! se è sono articoli validi come per i fornitori di seguito /* CustomerSupplier[] customerSuppliers = customerSupplierRepository.GetAll().ToArray(); var filteredItems = customerSuppliers.Where( item => !(String.IsNullOrEmpty(item.BusinessName)) && item.BusinessName.IndexOf(c.SupplierMaker, StringComparison.InvariantCultureIgnoreCase) >= 0); if (filteredItems.Count() == 0) throw new Exception(); c.Article.CodSupplierMaker = filteredItems.Single().CodCustomerSupplier; */ var flexoEx = taskExecutorRepository.GetSingle(c.CodTaskExecutor); var maxCyl = flexoEx.TaskExecutorCylinders.Max(x => x.Z); var minCyl = flexoEx.TaskExecutorCylinders.Where(y => y.Z != 0).Min(x => x.Z); c.FormatMax = c.FlexoWidth + "x" + c.GetCmFromZ(maxCyl ?? 0);// ((double)maxCyl / 8) * 2.54; c.FormatMin = 0 + "x" + c.GetCmFromZ(minCyl ?? 0); taskExecutorRepository.Edit(c); taskExecutorRepository.Save(); return Json(new { redirectUrl = Url.Action(returnUrl, new { codTypeOfTask = returnCodTypeOfTask }) }); } catch (Exception ex) { ModelState.AddModelError(string.Empty, "Something went wrong. Message: " + ex.Message); } } //return url ViewBag.ReturnUrl = returnUrl; ViewBag.ReturnCodTypeOfTask = returnCodTypeOfTask; //If we come here, something went wrong. Return it back. //Load each type of base ViewBag.TypeOfTaskList = typeOfTaskRepository.GetAll().Where(y => y.CodCategoryOfTask == "STAMPA"); ViewBag.ActionMethod = "EditFlexo"; return PartialView("_EditAndCreateFlexo", c); }