public ActionResult <IEnumerable <ContactedPerson> > CreateContact([FromQuery] string Dni, [FromBody] IEnumerable <ContactedPerson> contacts) { foreach (var contact in contacts) { var contactFromRepo = _repository.ExistContactedPerson(contact.Dni); if (contactFromRepo == null) { _repository.CreateContact(contact); } var rel = _repository.ExitsRegisteredContact(Dni, contact.Dni); if (rel == null) { _repository.AssignContact(Dni, contact.Dni); } } _repository.SaveChanges(); return(Created("https://cotecapi.com/contacts", contacts)); }