public async Task <ActionResult <TbUserCompany> > PostTbUserCompany(TbUserCompany tbUserCompany) { if (TbUserCompanyExists(tbUserCompany.UserId, tbUserCompany.CompanyId)) { return(Conflict()); } _context.TbUserCompanies.Add(tbUserCompany); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (TbUserCompanyExists(tbUserCompany.UserId, tbUserCompany.CompanyId)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetTbUserCompany", new { id = tbUserCompany.UserId }, tbUserCompany)); }
public async Task <IActionResult> PutTbUserCompany(int id, TbUserCompany tbUserCompany) { if (id != tbUserCompany.Id) { return(BadRequest()); } //if (TbUserCompanyExists(tbUserCompany.UserId, tbUserCompany.CompanyId)) //{ // return Conflict(); //} _context.Entry(tbUserCompany).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TbUserCompanyExists(tbUserCompany.UserId, tbUserCompany.CompanyId)) { return(NotFound()); } else { throw; } } return(NoContent()); }