Exemplo n.º 1
0
        public ActionResult CreateFlatRoll(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 = "CreateFlatRoll";

            var x = new FlatRoll();

            //            TODO: Elaborazione dell'array del tipo di lavorazione che può svolgere.
            x.CodTypeOfTask = "STAMPAETICHROTOLO";

            return View(x);
        }
Exemplo n.º 2
0
        public ActionResult CreateFlatRoll(FlatRoll c, string returnUrl, string returnCodTypeOfTask)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    c.CodTaskExecutor = taskExecutorRepository.GetNewCode(c);
                    taskExecutorRepository.Add(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);
                }
            }

            ViewBag.ReturnUrl = returnUrl;
            ViewBag.ReturnCodTypeOfTask = returnCodTypeOfTask;

            //Load each type of base
            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 = "CreateFlatRoll";
            return PartialView("_EditAndCreateFlatRoll", c);
        }
Exemplo n.º 3
0
        public ActionResult EditFlatRoll(FlatRoll c, string returnUrl, string returnCodTypeOfTask)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    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);
                }
            }

            //If we come here, something went wrong. Return it back.      

            ViewBag.ReturnUrl = returnUrl;
            ViewBag.ReturnCodTypeOfTask = returnCodTypeOfTask;

            //Load each type of base
            ViewBag.TypeOfTaskList = typeOfTaskRepository.GetAll().Where(y => y.CodCategoryOfTask == "STAMPA");

            ViewBag.ActionMethod = "EditFlatRoll";
            return PartialView("_EditAndCreateFlatRoll", c);
        }