Ejemplo n.º 1
0
 public IActionResult Create(TSuplier suplier, string actionType)
 {
     if (actionType == "Add")
     {
         if (ModelState.IsValid)
         {
             try{
                 _dbContext.TSupliers.Add(suplier);
                 _dbContext.SaveChanges();
             }
             catch {}
         }
         else
         {
             return(View(suplier));
         }
     }
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 2
0
        public IActionResult Edit(TSuplier suplier, string actionType, int?ProdId, int panel)
        {
            if (actionType == "Cancel")
            {
                return(RedirectToAction("Index"));
            }
            if (actionType == "Update")
            {
                if (ModelState.IsValid)
                {
                    try{
                        _dbContext.TSupliers.Update(suplier);
                        _dbContext.SaveChanges();
                    }
                    catch (Exception ex) {
                        string mensaje = ex.Message;
                    }
                }
                else
                {
                }
            }

            //var model = _dbContext.TSupliers
            //    .SingleOrDefault(u => u.SupId.Equals(id));

            string sName = suplier.SupRasoc + " " + suplier.SupNif;

            ViewData["sName"] = sName;
            ViewData["SupId"] = suplier.SupId;


            CreateViewBags(suplier.SupId, ProdId);

            ViewData["panel"] = panel;
            return(View("Edit", suplier));
            //return RedirectToAction("Index");
        }
Ejemplo n.º 3
0
        public IActionResult Edit(TSuplier suplier, string actionType, int?ProdId, int panel)
        {
            if (actionType == "Update")
            {
                if (ModelState.IsValid)
                {
                    try{
                        _dbContext.TSupliers.Update(suplier);
                        _dbContext.SaveChanges();
                    }
                    catch {}
                }
                else
                {
                }
            }

            CreateViewBags(suplier.SupId, ProdId);

            ViewData["panel"] = panel;
            return(View("Edit", suplier));
            //return RedirectToAction("Index");
        }