public async Task <ActionResult <MotorbikeModel> > PostMotorbikeModel(MotorbikeModel motorbikeModel) { _context.motorbikes.Add(motorbikeModel); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMotorbikeModel", new { id = motorbikeModel.Id }, motorbikeModel)); }
public async Task <IActionResult> PutMotorbikeModel(Guid id, MotorbikeModel motorbikeModel) { if (id != motorbikeModel.Id) { return(BadRequest()); } var motorbike = new MotorbikeModel { Id = motorbikeModel.Id, ManufacturerId = motorbikeModel.ManufacturerId, Year = motorbikeModel.Year, QuantityInStock = motorbikeModel.QuantityInStock, Model = motorbikeModel.Model, EngineId = motorbikeModel.EngineId, HasWindVisor = motorbikeModel.HasWindVisor, Color = motorbikeModel.Color, CreatedOn = motorbikeModel.CreatedOn, AmendedOn = DateTime.UtcNow }; _context.Entry(motorbike).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MotorbikeModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }