public async Task <ActionResult <DbManufacturer> > PostDbManufacturer(DbManufacturer dbManufacturer) { _context.Manufacturer.Add(dbManufacturer); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDbManufacturer", new { id = dbManufacturer.ID }, dbManufacturer)); }
public async Task <IActionResult> PutDbManufacturer(int id, DbManufacturer dbManufacturer) { if (id != dbManufacturer.ID) { return(BadRequest()); } _context.Entry(dbManufacturer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DbManufacturerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void Insert(DbManufacturer manufacturer, DbCarDetail carDetail) { unixDbContext.Manufacturer.Add(manufacturer); unixDbContext.CarDetail.Add(carDetail); unixDbContext.SaveChanges(); unixDbContext.Car.Add(new DbCar(manufacturer.ID, carDetail.ID)); unixDbContext.SaveChanges(); }