public ActionResult VehiculoUpdt(int id)
        {
            vehiculo vehiculo           = bd.vehiculo.Find(id);
            List <SelectListItem> lista = Selects.Armar_Select_Clientes();

            ViewBag.propietario = lista;
            return(View(vehiculo));
        }
        public ActionResult VehiculoAdd()
        {
            ClientesController    ClientesController = new ClientesController();
            List <SelectListItem> lista = Selects.Armar_Select_Clientes();

            ViewBag.propietario = lista;

            return(View());
        }
        public ActionResult VehiculoUpdt(vehiculo vehiculo, int id)
        {
            ClientesController    ClientesController = new ClientesController();
            List <SelectListItem> lis = Selects.Armar_Select_Clientes();

            if (vehiculo != null)
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        /* vehiculo.vehiculo_id = id;
                         * bd.Entry(vehiculo).State = EntityState.Modified;
                         * bd.SaveChanges();
                         */

                        // USANDO PROCEDIMIENTOS
                        bd.SP_UPDT_VEHICULO(vehiculo.vehiculo_id, vehiculo.marca, vehiculo.modelo, vehiculo.color, vehiculo.anno.ToString(), vehiculo.propietario_id);
                        bd.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                    catch (Exception e)
                    {
                        ViewBag.propietario = new SelectList(lis, "Value", "Text", vehiculo.propietario_id);;
                        return(View(vehiculo));
                    }
                }
                else
                {
                    ViewBag.propietario = new SelectList(lis, "Value", "Text", vehiculo.propietario_id);;
                    return(View(vehiculo));
                }
            }
            ViewBag.propietario = new SelectList(lis, "Value", "Text", vehiculo.propietario_id);;
            return(View(vehiculo));
        }
 public ActionResult VehiculoAdd(vehiculo vehiculo)
 {
     if (ModelState.IsValid)
     {
         try
         {
             bd.SP_INS_VEHICULO(vehiculo.marca, vehiculo.modelo, vehiculo.color, vehiculo.anno.ToString(), vehiculo.propietario_id);
             bd.SaveChanges();
             return(RedirectToAction("Index"));
         }
         catch (Exception e)
         {
             List <SelectListItem> lista = Selects.Armar_Select_Clientes();
             ViewBag.propietario = lista;
             return(View(vehiculo));
         }
     }
     else
     {
         List <SelectListItem> lista = Selects.Armar_Select_Clientes();
         ViewBag.propietario = lista;
         return(View(vehiculo));
     }
 }