public async Task<IHttpActionResult> Put(Company company) { if (company == null) { return BadRequest("Argument Null"); } var existing = await dbContext.Companies.FirstOrDefaultAsync(c => c.Id == company.Id); if (existing == null) { return NotFound(); } existing.Name = company.Name; await dbContext.SaveChangesAsync(); return Ok(); }
public async Task<IHttpActionResult> Post(Company company) { if (company == null) { return BadRequest("Argument Null"); } var companyExists = await dbContext.Companies.AnyAsync(c => c.Id == company.Id); if (companyExists) { return BadRequest("Exists"); } dbContext.Companies.Add(company); await dbContext.SaveChangesAsync(); return Ok(); }