public async Task <ActionResult <Manufacturer> > Post([FromBody] Manufacturer manufacturer) { if (manufacturer == null) { return(BadRequest()); } db.Manufacturers.Add(manufacturer); await db.SaveChangesAsync(); return(Ok(manufacturer)); }
public async Task <ActionResult <Weapon> > Post([FromBody] Weapon weapon) { if (weapon == null) { return(BadRequest()); } Caliber caliberPresence = db.Calibers.FirstOrDefault(item => item.Title == weapon.Caliber); if (caliberPresence == null) { db.Calibers.Add(new Caliber(weapon.Caliber)); } db.Weapons.Add(weapon); await db.SaveChangesAsync(); return(Ok(weapon)); }