public async Task <IActionResult> PutBike(int id, BikeDto bike) { Bike b = BikeDto.FromBikeDto(bike); if (id != b.Id) { return(BadRequest()); } _context.Entry(b).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BikeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <BikeDto> > PostBike(BikeDto bike) { Bike b = BikeDto.FromBikeDto(bike); _context.Bikes.Add(b); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBike", new { id = bike.Id }, BikeDto.ToBikeDto(b))); }