public ActionResult Edit(StockRepuesto stock)
        {
            bool stockExistente = StockRepuestoExistente(stock.RepuestoId);

            if (ModelState.IsValid && !stockExistente)
            {
                db.Entry(stock).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            if (stockExistente)
            {
                ModelState.AddModelError("", "Ya existe un stock asociado a este repuesto.");
            }

            ViewBag.RepuestoId = new SelectList(db.Proveedores, "ProveedorId", "Nombre", stock.RepuestoId);
            return(View(stock));
        }
        public ActionResult Create(StockRepuesto stock)
        {
            bool stockExistente = StockRepuestoExistente(stock.RepuestoId);

            if (ModelState.IsValid && !stockExistente)
            {
                db.StockRepuestos.Add(stock);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            if (stockExistente)
            {
                ModelState.AddModelError("", "Ya existe un stock asociado a este repuesto.");
            }

            ViewBag.RepuestoId = new SelectList(db.Repuestos, "RepuestoId", "Nombre", stock.RepuestoId);
            return(View(stock));
        }