public async Task <IActionResult> PutContactAndSkill(long id, ContactAndSkill contactAndSkill) { if (id != contactAndSkill.id) { return(BadRequest()); } var result = await _context.ContactAnsSkillTable.Where( p => p.skillId == contactAndSkill.skillId && p.contactId == contactAndSkill.contactId).ToListAsync(); if (result.Count == 0) { _context.Entry(contactAndSkill).State = EntityState.Modified; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactAndSkillExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <ContactAndSkill> > PostContactAndSkill(ContactAndSkill contactAndSkill) { var result = await _context.ContactAnsSkillTable.Where( p => p.skillId == contactAndSkill.skillId && p.contactId == contactAndSkill.contactId).ToListAsync(); if (result.Count == 0) { _context.ContactAnsSkillTable.Add(contactAndSkill); await _context.SaveChangesAsync(); return(CreatedAtAction("GetContactAndSkill", new { id = contactAndSkill.id }, contactAndSkill)); } else { return(BadRequest()); } }