コード例 #1
0
        public ActionResult EditPrePostPress(string id, string returnUrl)
        {
            ViewBag.ReturnUrl = returnUrl;
            ViewBag.returnCodTypeOfTask = "INPIANO";

            PrePostPress tskEx = new PrePostPress();
            tskEx = (PrePostPress)taskExecutorRepository.GetSingle(id);

            if (tskEx == null)
                return HttpNotFound();

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

            //is used to know where we are from and go
            ViewBag.ActionMethod = "EditPrePostPress";
            return View(tskEx);
        }
コード例 #2
0
        public ActionResult EditPrePostPress(PrePostPress c, string returnUrl, string returnCodTypeOfTask)

        {
            if (ModelState.IsValid)
            {
                try
                {
                    /* controllare le lastre
                    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;

                    */

                    taskExecutorRepository.Edit(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;

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

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

            //multi submit
            ViewBag.ActionMethod = "EditPrePostPress";
            return PartialView("_EditAndCreatePrePostPress", c);
        }
コード例 #3
0
        public ActionResult CreatePrePostPress(PrePostPress 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.TimeStampTable = DateTime.Now;
                    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;

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


            //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 = "CreatePrePostPress";
            return PartialView("_EditAndCreatePrePostPress", c);
        }