public async Task <IActionResult> PutConsoleRentalConsole(int id, ConsoleRental consoleRental) { if (id != consoleRental.Id) { return(BadRequest()); } _context.Entry(consoleRental).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ConsoleRentalConsoleExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <ConsoleRental> > PostConsoleRentalConsole(ConsoleRental consoleRental) { _context.ConsoleRentals.Add(consoleRental); await _context.SaveChangesAsync(); return(CreatedAtAction("GetConsoleRental", new { id = consoleRental.Id }, consoleRental)); }
public async Task <ActionResult <ConsoleRental> > GetConsoleRentalConsole(int id) { // var consoleRental = await _context.ConsoleRentals.FindAsync(id); // ConsoleRental consoleRentalFind = await _context.ConsoleRentals.FindAsync(id); ConsoleRental consoleRentalJoin = await _context.ConsoleRentals .Join( _context.Consoles, consoleRental => consoleRental.Console.Id, console => console.Id, (consoleRental, console) => new ConsoleRental { Id = consoleRental.Id, StartDate = consoleRental.StartDate, EndDate = consoleRental.EndDate, CustomerName = consoleRental.CustomerName, Console = console }).FirstOrDefaultAsync(i => i.Id == id); if (consoleRentalJoin == null) { return(NotFound()); } return(consoleRentalJoin); }