public ActionResult Return(int id) { //var rentaDevolucion = _context.RentasDevoluciones // .Include(r => r.Cliente) // .Include(r => r.Empleado) // .Include(r => r.Inspeccion) // .Include(r => r.Vehiculo) // .FirstOrDefaultAsync(m => m.IdRenta == id); Vehiculo vehiculo = (from v in _context.Vehiculos join r in _context.RentasDevoluciones on v.IdVehiculo equals r.IdVehiculo where r.IdRenta == id select v).FirstOrDefault(); vehiculo.Estado = true; RentaDevolucion rentaDevolucione = (from r in _context.RentasDevoluciones.Where(a => a.IdRenta == id) select r).FirstOrDefault(); rentaDevolucione.Estado = true; rentaDevolucione.FechaDevolucion = DateTime.Now; _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Edit(int id, [Bind("IdRenta,IdCliente,IdEmpleado,IdInspeccion,IdVehiculo,FechaRenta,FechaDevolucion,MontoDiario,CantidadDias,Comentario,Estado")] RentaDevolucion rentaDevolucion) { if (id != rentaDevolucion.IdRenta) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(rentaDevolucion); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RentaDevolucionExists(rentaDevolucion.IdRenta)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdCliente"] = new SelectList(_context.Clientes, "IdCliente", "Nombre", rentaDevolucion.IdCliente); ViewData["IdEmpleado"] = new SelectList(_context.Empleados, "IdEmpleado", "Nombre", rentaDevolucion.IdEmpleado); ViewData["IdVehiculo"] = new SelectList(_context.Vehiculos.Where(c => c.Estado == true), "IdVehiculo", "Descripcion", rentaDevolucion.IdVehiculo); ViewData["IdInspeccion"] = new SelectList(_context.Inspecciones, "IdTransaccion", "IdTransaccion", rentaDevolucion.IdInspeccion); return(View(rentaDevolucion)); }
public ActionResult DeleteConfirmed(int id) { RentaDevolucion rentaDevolucion = db.RentaDevolucion.Find(id); db.RentaDevolucion.Remove(rentaDevolucion); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "noPrestamo,idEmpleado,idEquipo,idUsuadio,fechaP,fechaD,comentario,estadoPrestamo")] RentaDevolucion rentaDevolucion) { if (ModelState.IsValid) { db.Entry(rentaDevolucion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.idEmpleado = new SelectList(db.Empleado, "idEmpleado", "nombreEmpleado", rentaDevolucion.idEmpleado); ViewBag.idEquipo = new SelectList(db.Equipo, "idEquipo", "nombreEquipo", rentaDevolucion.idEquipo); ViewBag.idUsuadio = new SelectList(db.Usuario, "idUsuario", "nombreUsuario", rentaDevolucion.idUsuadio); return(View(rentaDevolucion)); }
// GET: RentaDevolucion/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RentaDevolucion rentaDevolucion = db.RentaDevolucion.Find(id); if (rentaDevolucion == null) { return(HttpNotFound()); } return(View(rentaDevolucion)); }
public async Task <IActionResult> Create([Bind("IdRenta,IdCliente,IdEmpleado,IdInspeccion,IdVehiculo,FechaRenta,FechaDevolucion,MontoDiario,CantidadDias,Comentario,Estado")] RentaDevolucion rentaDevolucion) { if (ModelState.IsValid) { _context.Add(rentaDevolucion); Vehiculo vehiculo = (from r in _context.Vehiculos.Where(a => a.IdVehiculo == rentaDevolucion.IdVehiculo) select r).FirstOrDefault(); vehiculo.Estado = false; await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdCliente"] = new SelectList(_context.Clientes, "IdCliente", "Nombre", rentaDevolucion.IdCliente); ViewData["IdEmpleado"] = new SelectList(_context.Empleados, "IdEmpleado", "Nombre", rentaDevolucion.IdEmpleado); ViewData["IdVehiculo"] = new SelectList(_context.Vehiculos.Where(c => c.Estado == true), "IdVehiculo", "Descripcion", rentaDevolucion.IdVehiculo); ViewData["IdInspeccion"] = new SelectList(_context.Inspecciones, "IdTransaccion", "IdTransaccion", rentaDevolucion.IdInspeccion); return(View(rentaDevolucion)); }
// GET: RentaDevolucion/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RentaDevolucion rentaDevolucion = db.RentaDevolucion.Find(id); if (rentaDevolucion == null) { return(HttpNotFound()); } ViewBag.idEmpleado = new SelectList(db.Empleado, "idEmpleado", "nombreEmpleado", rentaDevolucion.idEmpleado); ViewBag.idEquipo = new SelectList(db.Equipo, "idEquipo", "nombreEquipo", rentaDevolucion.idEquipo); ViewBag.idUsuadio = new SelectList(db.Usuario, "idUsuario", "nombreUsuario", rentaDevolucion.idUsuadio); return(View(rentaDevolucion)); }