Esempio n. 1
0
        public ActionResult ControlTableRollEstimatedOnTime(ControlTableRollEstimatedOnTime c, string returnUrl, string returnCodTypeOfTask)
        {
            ViewBag.ReturnCodTypeOfTask = returnCodTypeOfTask;
            ViewBag.ReturnUrl = returnUrl;

            if (ModelState.IsValid)
            {
                try
                {
                    // c.CostPerHourRunning = "10";
                    taskExecutorRepository.AddEstimatedOn(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);
                }
            }

            //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 = "ControlTableRollEstimatedOnTime";
            return PartialView("ControlTableRollEstimatedOnTime", c);
        }
Esempio n. 2
0
        public ActionResult TaskExecutorNewCost(TaskExecutorNewCostViewModel c, string FieldToPreventTwoSubmission, string returnUrl, string returnCodTypeOfTask)
        {

            var taskExecutor = taskExecutorRepository.GetSingle(c.CodTaskExecutor);
            TaskEstimatedOn tskEst = null;
            String retView = String.Empty;

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


            //if cost is just selected (to prevent two submissions)
            if (taskExecutor.SetTaskExecutorEstimatedOn.Count() != 0)
                return RedirectToAction("TaskExecutorCost", new { id = c.CodTaskExecutor });


            if (taskExecutor.CodTypeOfTask == null || !taskExecutor.CodTypeOfTask.StartsWith("STAMPA"))
            {
                // var optionTypeOfTaskList = typeOfTaskRepository.GetSingle(taskExecutor.CodTypeOfTask).OptionTypeOfTasks;

                // foreach (var item in optionTypeOfTaskList.Except(optionTypeOfTaskList.Where(x => x.CodOptionTypeOfTask == taskExecutor.CodTypeOfTask + "_NO")))
                {
                    switch (c.TypeTaskExecutorEstimatedOn)
                    {
                        case TaskEstimatedOn.EstimatedOnType.OnRun:
                            if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalRoll ||
                                taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalSheet)
                            {
                                tskEst = new DigitalOnRun();
                                retView = "DigitalOnRun";
                            }
                            else
                            {
                                tskEst = new TaskEstimatedOnRun();
                                retView = "TaskEstimatedOnRun";
                            }
                            break;
                        case TaskEstimatedOn.EstimatedOnType.OnTime:

                            if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalRoll ||
                                taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalSheet)
                            {
                                tskEst = new DigitalOnTime();
                                retView = "DigitalOnTime";
                            }
                            else
                            {
                                if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.ControlTableRoll)
                                {
                                    tskEst = new ControlTableRollEstimatedOnTime();
                                    retView = "ControlTableRollEstimatedOnTime";
                                }
                                else
                                {
                                    tskEst = new TaskEstimatedOnTime();
                                    retView = "TaskEstimatedOnTime";
                                }
                            }
                            break;
                        case TaskEstimatedOn.EstimatedOnType.OnMq:

                            if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.PlotterRoll ||
                                taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.PlotterSheet)
                            {
                                tskEst = new PlotterOnMq();
                                retView = "PlotterOnMq";
                            }
                            else
                            {
                                tskEst = new TaskEstimatedOnMq();
                                retView = "TaskEstimatedOnMq";
                            }
                            break;
                        case TaskEstimatedOn.EstimatedOnType.BindingOnTime:
                            break;
                        case TaskEstimatedOn.EstimatedOnType.BindingOnRun:
                            break;
                        default:
                            break;
                    }

                    //     tskEst.CodOptionTypeOfTask = item.CodOptionTypeOfTask;
                    taskExecutor.SetTaskExecutorEstimatedOn.Add(tskEst);

                }
            }
            else
            {
                switch (c.TypeTaskExecutorEstimatedOn)
                {
                    case TaskEstimatedOn.EstimatedOnType.OnRun:
                        if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalRoll ||
                            taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalSheet)
                        {
                            tskEst = new DigitalOnRun();
                            retView = "DigitalOnRun";
                        }
                        else
                        {
                            tskEst = new TaskEstimatedOnRun();
                            retView = "TaskEstimatedOnRun";
                        }
                        break;
                    case TaskEstimatedOn.EstimatedOnType.OnTime:

                        if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalRoll ||
                            taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalSheet)
                        {
                            tskEst = new DigitalOnTime();
                            retView = "DigitalOnTime";
                        }
                        else
                        {
                            if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.Flexo ||
                                taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalRoll)
                            {
                                tskEst = new RollEstimatedOnTime();
                                retView = "RollEstimatedOnTime";
                            }
                            else
                                if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.ControlTableRoll)
                                {
                                    tskEst = new ControlTableRollEstimatedOnTime();
                                    retView = "ControlTableRollEstimatedOnTime";
                                }
                                else
                                {
                                    if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.FlatRoll)
                                    {
                                        tskEst = new FlatRollEstimatedOnTime();
                                        retView = "FlatRollEstimatedOnTime";
                                    }
                                    else
                                    {
                                        tskEst = new TaskEstimatedOnTime();
                                        retView = "TaskEstimatedOnTime";
                                    }
                                }
                        }
                        break;
                    case TaskEstimatedOn.EstimatedOnType.OnMq:

                        if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.PlotterRoll ||
                            taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.PlotterSheet)
                        {
                            tskEst = new PlotterOnMq();
                            retView = "PlotterOnMq";
                        }
                        else
                        {
                            tskEst = new TaskEstimatedOnMq();
                            retView = "TaskEstimatedOnMq";
                        }
                        break;
                    case TaskEstimatedOn.EstimatedOnType.BindingOnTime:
                        break;
                    case TaskEstimatedOn.EstimatedOnType.BindingOnRun:
                        break;
                    default:
                        break;
                }

                //Attenzione nella stampa manca l'optiontypeoftask
                taskExecutor.SetTaskExecutorEstimatedOn.Add(tskEst);

            }


            //se diverso da stampa allora devo creare un numero di costi pari alle opzioni di TypeOfTask

            taskExecutorRepository.Edit(taskExecutor);
            taskExecutorRepository.Save();

            GenEmptyStep(taskExecutor);

            ViewBag.ActionMethod = retView;

            //if there are more than one cost return different model and different view
            if (taskExecutor.SetTaskExecutorEstimatedOn.Count > 1)
            {
                ViewBag.ActionMethod = ViewBag.ActionMethod + "s";
                return View("TaskEstimatedOn", taskExecutor.SetTaskExecutorEstimatedOn.ToList());
            }
            else
            {
                return View(ViewBag.ActionMethod, tskEst);
            }

        }