Exemplo n.º 1
0
        public ActionResult EditAnilox(AniloxViewModel c)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    articleRepository.SincroSupplier(c.Article, customerSupplierRepository, c.SupplierMaker, c.SupplyerBuy);
                    articleRepository.Edit(c.Article);
                    articleRepository.Save();
                    return Json(new { redirectUrl = Url.Action("IndexAnilox") });
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError(string.Empty, "Something went wrong. Message: " + ex.Message);
                }
            }

            foreach (ModelState modelState in ViewData.ModelState.Values)
            {
                foreach (ModelError error in modelState.Errors)
                {
                    Console.WriteLine(error);
                }
            }

            //If we come here, something went wrong. Return it back. 
            //multi submit
            ViewBag.ActionMethod = "EditAnilox";
            return PartialView("_EditAndCreateAnilox", c);
        }
Exemplo n.º 2
0
        public ActionResult EditAnilox(string id)
        {
            AniloxViewModel viewModel = new AniloxViewModel();
            viewModel.Article = (Anilox)articleRepository.GetSingle(id);

            //get producer and maker

            if (viewModel.Article.CodArticle == "")
                return HttpNotFound();

            //is used to know where we are from and go
            ViewBag.ActionMethod = "EditAnilox";
            return View("EditAnilox", viewModel);
        }
Exemplo n.º 3
0
        public ActionResult CreateAnilox(AniloxViewModel c)
        {
            if (ModelState.IsValid)
            {
                try
                {

                    c.Article.CodArticle = articleRepository.GetNewCode(c.Article, customerSupplierRepository, c.SupplierMaker, c.SupplyerBuy);

                    //   c.Article.ArticleName =  c.Article.ToString();
                    articleRepository.Add(c.Article);

                    articleRepository.Save();
                    return Json(new { redirectUrl = Url.Action("IndexAnilox") });
                }
                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 = "CreateAnilox";
            return PartialView("_EditAndCreateAnilox", c);

        }